Skip to content

Commit

Permalink
feat(issue-150): required fields for policies
Browse files Browse the repository at this point in the history
  • Loading branch information
Breee committed Sep 3, 2024
1 parent 16a62b9 commit 9818cd9
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 0 deletions.
1 change: 1 addition & 0 deletions apis/openidclient/v1alpha1/zz_clientclientpolicy_types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions apis/openidclient/v1alpha1/zz_clientgrouppolicy_types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions apis/openidclient/v1alpha1/zz_clientrolepolicy_types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions apis/openidclient/v1alpha1/zz_clientuserpolicy_types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 37 additions & 0 deletions config/openidclient/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,55 @@ func Configure(p *config.Provider) {

p.AddResourceConfigurator("keycloak_openid_client_client_policy", func(r *config.Resource) {
r.ShortGroup = Group

if s, ok := r.TerraformResource.Schema["decisionStrategy"]; ok {
s.Optional = false
s.Computed = false
}

if s, ok := r.TerraformResource.Schema["logic"]; ok {
s.Optional = false
s.Computed = false
}
})

p.AddResourceConfigurator("keycloak_openid_client_group_policy", func(r *config.Resource) {
r.ShortGroup = Group
if s, ok := r.TerraformResource.Schema["decisionStrategy"]; ok {
s.Optional = false
s.Computed = false
}

if s, ok := r.TerraformResource.Schema["logic"]; ok {
s.Optional = false
s.Computed = false
}
})

p.AddResourceConfigurator("keycloak_openid_client_role_policy", func(r *config.Resource) {
r.ShortGroup = Group
if s, ok := r.TerraformResource.Schema["decisionStrategy"]; ok {
s.Optional = false
s.Computed = false
}

if s, ok := r.TerraformResource.Schema["logic"]; ok {
s.Optional = false
s.Computed = false
}
})

p.AddResourceConfigurator("keycloak_openid_client_user_policy", func(r *config.Resource) {
r.ShortGroup = Group
if s, ok := r.TerraformResource.Schema["decisionStrategy"]; ok {
s.Optional = false
s.Computed = false
}

if s, ok := r.TerraformResource.Schema["logic"]; ok {
s.Optional = false
s.Computed = false
}
})

p.AddResourceConfigurator("keycloak_openid_client_permissions", func(r *config.Resource) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,10 @@ spec:
rule: '!(''*'' in self.managementPolicies || ''Create'' in self.managementPolicies
|| ''Update'' in self.managementPolicies) || has(self.forProvider.clients)
|| (has(self.initProvider) && has(self.initProvider.clients))'
- message: spec.forProvider.logic is a required parameter
rule: '!(''*'' in self.managementPolicies || ''Create'' in self.managementPolicies
|| ''Update'' in self.managementPolicies) || has(self.forProvider.logic)
|| (has(self.initProvider) && has(self.initProvider.logic))'
- message: spec.forProvider.name is a required parameter
rule: '!(''*'' in self.managementPolicies || ''Create'' in self.managementPolicies
|| ''Update'' in self.managementPolicies) || has(self.forProvider.name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,10 @@ spec:
rule: '!(''*'' in self.managementPolicies || ''Create'' in self.managementPolicies
|| ''Update'' in self.managementPolicies) || has(self.forProvider.groups)
|| (has(self.initProvider) && has(self.initProvider.groups))'
- message: spec.forProvider.logic is a required parameter
rule: '!(''*'' in self.managementPolicies || ''Create'' in self.managementPolicies
|| ''Update'' in self.managementPolicies) || has(self.forProvider.logic)
|| (has(self.initProvider) && has(self.initProvider.logic))'
- message: spec.forProvider.name is a required parameter
rule: '!(''*'' in self.managementPolicies || ''Create'' in self.managementPolicies
|| ''Update'' in self.managementPolicies) || has(self.forProvider.name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,10 @@ spec:
- forProvider
type: object
x-kubernetes-validations:
- message: spec.forProvider.logic is a required parameter
rule: '!(''*'' in self.managementPolicies || ''Create'' in self.managementPolicies
|| ''Update'' in self.managementPolicies) || has(self.forProvider.logic)
|| (has(self.initProvider) && has(self.initProvider.logic))'
- message: spec.forProvider.name is a required parameter
rule: '!(''*'' in self.managementPolicies || ''Create'' in self.managementPolicies
|| ''Update'' in self.managementPolicies) || has(self.forProvider.name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,10 @@ spec:
rule: '!(''*'' in self.managementPolicies || ''Create'' in self.managementPolicies
|| ''Update'' in self.managementPolicies) || has(self.forProvider.decisionStrategy)
|| (has(self.initProvider) && has(self.initProvider.decisionStrategy))'
- message: spec.forProvider.logic is a required parameter
rule: '!(''*'' in self.managementPolicies || ''Create'' in self.managementPolicies
|| ''Update'' in self.managementPolicies) || has(self.forProvider.logic)
|| (has(self.initProvider) && has(self.initProvider.logic))'
- message: spec.forProvider.name is a required parameter
rule: '!(''*'' in self.managementPolicies || ''Create'' in self.managementPolicies
|| ''Update'' in self.managementPolicies) || has(self.forProvider.name)
Expand Down

0 comments on commit 9818cd9

Please sign in to comment.