@@ -5,34 +5,36 @@ import (
5
5
6
6
"github.com/hashicorp/terraform-plugin-framework/diag"
7
7
"github.com/hashicorp/terraform-plugin-framework/types"
8
+
8
9
"github.com/pomerium/enterprise-client-go/pb"
9
10
)
10
11
11
12
// PolicyModel represents the shared model for policy resources and data sources
12
13
type PolicyModel struct {
14
+ Description types.String `tfsdk:"description"`
15
+ Enforced types.Bool `tfsdk:"enforced"`
16
+ Explanation types.String `tfsdk:"explanation"`
13
17
ID types.String `tfsdk:"id"`
14
18
Name types.String `tfsdk:"name"`
15
- Description types.String `tfsdk:"description"`
16
19
NamespaceID types.String `tfsdk:"namespace_id"`
17
20
PPL PolicyLanguage `tfsdk:"ppl"`
18
21
Rego types.List `tfsdk:"rego"`
19
- Enforced types.Bool `tfsdk:"enforced"`
20
- Explanation types.String `tfsdk:"explanation"`
21
22
Remediation types.String `tfsdk:"remediation"`
22
23
}
23
24
24
25
func ConvertPolicyToPB (ctx context.Context , src * PolicyResourceModel ) (* pb.Policy , diag.Diagnostics ) {
25
26
var diagnostics diag.Diagnostics
26
27
27
28
pbPolicy := & pb.Policy {
28
- Id : src .ID .ValueString (),
29
- Name : src .Name .ValueString (),
30
- Description : src .Description .ValueString (),
31
- NamespaceId : src .NamespaceID .ValueString (),
32
- Ppl : string (src .PPL .PolicyJSON ),
33
- Enforced : src .Enforced .ValueBool (),
34
- Explanation : src .Explanation .ValueString (),
35
- Remediation : src .Remediation .ValueString (),
29
+ OriginatorId : originatorID ,
30
+ Id : src .ID .ValueString (),
31
+ Name : src .Name .ValueString (),
32
+ Description : src .Description .ValueString (),
33
+ NamespaceId : src .NamespaceID .ValueString (),
34
+ Ppl : string (src .PPL .PolicyJSON ),
35
+ Enforced : src .Enforced .ValueBool (),
36
+ Explanation : src .Explanation .ValueString (),
37
+ Remediation : src .Remediation .ValueString (),
36
38
}
37
39
diagnostics .Append (src .Rego .ElementsAs (ctx , & pbPolicy .Rego , false )... )
38
40
0 commit comments