Skip to content

Commit 6d02d20

Browse files
committed
Fix constraint template
1 parent be7edd7 commit 6d02d20

File tree

2 files changed

+14
-53
lines changed

2 files changed

+14
-53
lines changed

internal/commands/constraint_template.tpl

+14-5
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,21 @@ metadata:
1010
{{- end }}
1111
name: {{ .Name }}
1212
spec:
13-
{{- if .Matchers }}
14-
match: {{- .GetAnnotation "matchers" | toIndentYAML 2 | nindent 4 }}
15-
{{- end }}
1613
{{- if ne .Enforcement "deny" }}
1714
enforcementAction: {{ .Enforcement }}
1815
{{- end -}}
19-
{{- if .AnnotationParameters }}
20-
parameters: {{- .AnnotationParameters | toIndentYAML 2 | nindent 4 }}
16+
{{- if or .AnnotationKindMatchers .AnnotationNamespaceMatchers .AnnotationExcludedNamespaceMatchers .AnnotationLabelSelectorMatcher }}
17+
match:
18+
{{- if .AnnotationExcludedNamespaceMatchers }}
19+
excludedNamespaces: {{- .AnnotationExcludedNamespaceMatchers | toIndentYAML 2 | nindent 6 }}
20+
{{- end }}
21+
{{- if .AnnotationKindMatchers }}
22+
kinds: {{- .AnnotationKindMatchers | toJSON | fromJSON | toIndentYAML 2 | nindent 6 }}
23+
{{- end }}
24+
{{- if .AnnotationLabelSelectorMatcher }}
25+
labelSelector: {{- .AnnotationLabelSelectorMatcher | toJSON | fromJSON | toIndentYAML 2 | nindent 6 }}
26+
{{- end }}
27+
{{- if .AnnotationNamespaceMatchers }}
28+
namespaces: {{- .AnnotationNamespaceMatchers | toIndentYAML 2 | nindent 6 }}
29+
{{- end }}
2130
{{- end }}

test/custom/constraint_Test.yaml

-48
Original file line numberDiff line numberDiff line change
@@ -32,51 +32,3 @@ spec:
3232
- dev
3333
- stage
3434
- prod
35-
parameters:
36-
super:
37-
id: ""
38-
schema: ""
39-
ref: null
40-
description: |-
41-
super duper cool parameter with a description
42-
on two lines.
43-
type: string
44-
format: ""
45-
title: ""
46-
default: null
47-
maximum: null
48-
exclusivemaximum: false
49-
minimum: null
50-
exclusiveminimum: false
51-
maxlength: null
52-
minlength: null
53-
pattern: ""
54-
maxitems: null
55-
minitems: null
56-
uniqueitems: false
57-
multipleof: null
58-
enum: []
59-
maxproperties: null
60-
minproperties: null
61-
required: []
62-
items: null
63-
allof: []
64-
oneof: []
65-
anyof: []
66-
not: null
67-
properties: {}
68-
additionalproperties: null
69-
patternproperties: {}
70-
dependencies: {}
71-
additionalitems: null
72-
definitions: {}
73-
externaldocs: null
74-
example: null
75-
nullable: false
76-
xpreserveunknownfields: null
77-
xembeddedresource: false
78-
xintorstring: false
79-
xlistmapkeys: []
80-
xlisttype: null
81-
xmaptype: null
82-
xvalidations: []

0 commit comments

Comments
 (0)