From 76621d376ce57aa5b4bae801826e6d494ee545a5 Mon Sep 17 00:00:00 2001 From: sangkenlee Date: Thu, 9 May 2024 01:49:23 +0900 Subject: [PATCH] =?UTF-8?q?=ED=8C=8C=EB=9D=BC=EB=AF=B8=ED=84=B0=EB=A5=BC?= =?UTF-8?q?=20=EB=AA=85=EC=8B=9C=ED=95=98=EC=A7=80=20=EC=95=8A=EC=9D=80=20?= =?UTF-8?q?=EC=A0=95=EC=B1=85=EC=9D=84=20=EC=A0=81=EC=9A=A9=ED=95=A0=20?= =?UTF-8?q?=EB=95=8C=20=EB=B2=84=EA=B7=B8=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/policy-template/policy-operator.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/internal/policy-template/policy-operator.go b/internal/policy-template/policy-operator.go index 0626ea11..98c81311 100644 --- a/internal/policy-template/policy-operator.go +++ b/internal/policy-template/policy-operator.go @@ -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{} @@ -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", @@ -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{{