Skip to content

Commit

Permalink
Merge pull request #483 from sangkenlee/policy-noparam-fix
Browse files Browse the repository at this point in the history
파라미터를 명시하지 않은 정책을 적용할 때 버그 수정
  • Loading branch information
ktkfree authored May 9, 2024
2 parents 2495843 + 76621d3 commit 62744a4
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions internal/policy-template/policy-operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func PolicyToTksPolicyCR(policy *model.Policy) *TKSPolicy {
return nil
}

var params *apiextensionsv1.JSON = nil
var params *apiextensionsv1.JSON = &apiextensionsv1.JSON{Raw: []byte("{}")}

var jsonResult map[string]interface{}

Expand Down Expand Up @@ -86,6 +86,14 @@ func PolicyTemplateToTksPolicyTemplateCR(policyTemplate *model.PolicyTemplate) *
labels[PartOfKey] = PartOfVal
labels[TemplateIDLabel] = policyTemplate.ID.String()

var validation *Validation = nil

if len(policyTemplate.ParametersSchema) > 0 {
validation = &Validation{
OpenAPIV3Schema: ParamDefsToJSONSchemaProeprties(policyTemplate.ParametersSchema, false),
}
}

return &TKSPolicyTemplate{
TypeMeta: metav1.TypeMeta{
APIVersion: "tkspolicy.openinfradev.github.io/v1",
Expand All @@ -103,9 +111,7 @@ func PolicyTemplateToTksPolicyTemplateCR(policyTemplate *model.PolicyTemplate) *
Names: Names{
Kind: policyTemplate.Kind,
},
Validation: &Validation{
OpenAPIV3Schema: ParamDefsToJSONSchemaProeprties(policyTemplate.ParametersSchema, false),
},
Validation: validation,
},
},
Targets: []Target{{
Expand Down

0 comments on commit 62744a4

Please sign in to comment.