Skip to content

Fix constraint template #591

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 1, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix constraint template
  • Loading branch information
mrueg committed Feb 25, 2025
commit c373ce029d0f096588e62f016dfbec28c54defe8
19 changes: 14 additions & 5 deletions internal/commands/constraint_template.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,21 @@ metadata:
{{- end }}
name: {{ .Name }}
spec:
{{- if .Matchers }}
match: {{- .GetAnnotation "matchers" | toIndentYAML 2 | nindent 4 }}
{{- end }}
{{- if ne .Enforcement "deny" }}
enforcementAction: {{ .Enforcement }}
{{- end -}}
{{- if .AnnotationParameters }}
parameters: {{- .AnnotationParameters | toIndentYAML 2 | nindent 4 }}
{{- if or .AnnotationKindMatchers .AnnotationNamespaceMatchers .AnnotationExcludedNamespaceMatchers .AnnotationLabelSelectorMatcher }}
match:
{{- if .AnnotationExcludedNamespaceMatchers }}
excludedNamespaces: {{- .AnnotationExcludedNamespaceMatchers | toIndentYAML 2 | nindent 6 }}
{{- end }}
{{- if .AnnotationKindMatchers }}
kinds: {{- .AnnotationKindMatchers | toJSON | fromJSON | toIndentYAML 2 | nindent 6 }}
{{- end }}
{{- if .AnnotationLabelSelectorMatcher }}
labelSelector: {{- .AnnotationLabelSelectorMatcher | toJSON | fromJSON | toIndentYAML 2 | nindent 6 }}
{{- end }}
{{- if .AnnotationNamespaceMatchers }}
namespaces: {{- .AnnotationNamespaceMatchers | toIndentYAML 2 | nindent 6 }}
{{- end }}
{{- end }}
48 changes: 0 additions & 48 deletions test/output/custom/constraint_Test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,51 +32,3 @@ spec:
- dev
- stage
- prod
parameters:
super:
id: ""
schema: ""
ref: null
description: |-
super duper cool parameter with a description
on two lines.
type: string
format: ""
title: ""
default: null
maximum: null
exclusivemaximum: false
minimum: null
exclusiveminimum: false
maxlength: null
minlength: null
pattern: ""
maxitems: null
minitems: null
uniqueitems: false
multipleof: null
enum: []
maxproperties: null
minproperties: null
required: []
items: null
allof: []
oneof: []
anyof: []
not: null
properties: {}
additionalproperties: null
patternproperties: {}
dependencies: {}
additionalitems: null
definitions: {}
externaldocs: null
example: null
nullable: false
xpreserveunknownfields: null
xembeddedresource: false
xintorstring: false
xlistmapkeys: []
xlisttype: null
xmaptype: null
xvalidations: []
Loading