Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 5 additions & 3 deletions api/policies.kyverno.io/v1alpha1/generating_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@
}

// Generation defines the configuration for the generation of resources.
// +kubebuilder:validation:XValidation:rule="(has(self.expression) && !has(self.template)) || (!has(self.expression) && has(self.template))",message="exactly one of expression or template must be set"
// +kubebuilder:validation:XValidation:rule="(has(self.expression) && self.expression != '' && !has(self.template)) || ((!has(self.expression) || self.expression == '') && has(self.template))",message="exactly one of expression or template must be set"

Check failure on line 216 in api/policies.kyverno.io/v1alpha1/generating_policy.go

View workflow job for this annotation

GitHub Actions / golangci-lint

File is not properly formatted (gci)
type Generation struct {
// Expression is a CEL expression that takes a list of resources to be generated.
// +optional
Expand All @@ -239,8 +239,10 @@
// GenerationTemplate declares generated resources as a YAML document with optional CEL interpolation.
type GenerationTemplate struct {
// Value is a YAML string, single or multi-document, defining the resources to generate.
// The namespace of each generated resource is taken from its rendered metadata.namespace,
// resources without a namespace are treated as cluster-scoped.
// The namespace of each generated resource is taken from its rendered metadata.namespace.
// For cluster-scoped policies, resources without a namespace are treated as cluster-scoped.
// For namespaced policies, resources without a namespace default to the policy's namespace,
// and any other namespace is rejected.
// +kubebuilder:validation:MinLength=1
Value string `json:"value"`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,10 @@ spec:
value:
description: |-
Value is a YAML string, single or multi-document, defining the resources to generate.
The namespace of each generated resource is taken from its rendered metadata.namespace,
resources without a namespace are treated as cluster-scoped.
The namespace of each generated resource is taken from its rendered metadata.namespace.
For cluster-scoped policies, resources without a namespace are treated as cluster-scoped.
For namespaced policies, resources without a namespace default to the policy's namespace,
and any other namespace is rejected.
minLength: 1
type: string
required:
Expand All @@ -199,8 +201,8 @@ spec:
type: object
x-kubernetes-validations:
- message: exactly one of expression or template must be set
rule: (has(self.expression) && !has(self.template)) || (!has(self.expression)
&& has(self.template))
rule: (has(self.expression) && self.expression != '' && !has(self.template))
|| ((!has(self.expression) || self.expression == '') && has(self.template))
minItems: 1
type: array
matchConditions:
Expand Down Expand Up @@ -898,8 +900,10 @@ spec:
value:
description: |-
Value is a YAML string, single or multi-document, defining the resources to generate.
The namespace of each generated resource is taken from its rendered metadata.namespace,
resources without a namespace are treated as cluster-scoped.
The namespace of each generated resource is taken from its rendered metadata.namespace.
For cluster-scoped policies, resources without a namespace are treated as cluster-scoped.
For namespaced policies, resources without a namespace default to the policy's namespace,
and any other namespace is rejected.
minLength: 1
type: string
required:
Expand All @@ -908,8 +912,8 @@ spec:
type: object
x-kubernetes-validations:
- message: exactly one of expression or template must be set
rule: (has(self.expression) && !has(self.template)) || (!has(self.expression)
&& has(self.template))
rule: (has(self.expression) && self.expression != '' && !has(self.template))
|| ((!has(self.expression) || self.expression == '') && has(self.template))
minItems: 1
type: array
matchConditions:
Expand Down Expand Up @@ -1606,8 +1610,10 @@ spec:
value:
description: |-
Value is a YAML string, single or multi-document, defining the resources to generate.
The namespace of each generated resource is taken from its rendered metadata.namespace,
resources without a namespace are treated as cluster-scoped.
The namespace of each generated resource is taken from its rendered metadata.namespace.
For cluster-scoped policies, resources without a namespace are treated as cluster-scoped.
For namespaced policies, resources without a namespace default to the policy's namespace,
and any other namespace is rejected.
minLength: 1
type: string
required:
Expand All @@ -1616,8 +1622,8 @@ spec:
type: object
x-kubernetes-validations:
- message: exactly one of expression or template must be set
rule: (has(self.expression) && !has(self.template)) || (!has(self.expression)
&& has(self.template))
rule: (has(self.expression) && self.expression != '' && !has(self.template))
|| ((!has(self.expression) || self.expression == '') && has(self.template))
minItems: 1
type: array
matchConditions:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,10 @@ spec:
value:
description: |-
Value is a YAML string, single or multi-document, defining the resources to generate.
The namespace of each generated resource is taken from its rendered metadata.namespace,
resources without a namespace are treated as cluster-scoped.
The namespace of each generated resource is taken from its rendered metadata.namespace.
For cluster-scoped policies, resources without a namespace are treated as cluster-scoped.
For namespaced policies, resources without a namespace default to the policy's namespace,
and any other namespace is rejected.
minLength: 1
type: string
required:
Expand All @@ -201,8 +203,8 @@ spec:
type: object
x-kubernetes-validations:
- message: exactly one of expression or template must be set
rule: (has(self.expression) && !has(self.template)) || (!has(self.expression)
&& has(self.template))
rule: (has(self.expression) && self.expression != '' && !has(self.template))
|| ((!has(self.expression) || self.expression == '') && has(self.template))
minItems: 1
type: array
matchConditions:
Expand Down Expand Up @@ -901,8 +903,10 @@ spec:
value:
description: |-
Value is a YAML string, single or multi-document, defining the resources to generate.
The namespace of each generated resource is taken from its rendered metadata.namespace,
resources without a namespace are treated as cluster-scoped.
The namespace of each generated resource is taken from its rendered metadata.namespace.
For cluster-scoped policies, resources without a namespace are treated as cluster-scoped.
For namespaced policies, resources without a namespace default to the policy's namespace,
and any other namespace is rejected.
minLength: 1
type: string
required:
Expand All @@ -911,8 +915,8 @@ spec:
type: object
x-kubernetes-validations:
- message: exactly one of expression or template must be set
rule: (has(self.expression) && !has(self.template)) || (!has(self.expression)
&& has(self.template))
rule: (has(self.expression) && self.expression != '' && !has(self.template))
|| ((!has(self.expression) || self.expression == '') && has(self.template))
minItems: 1
type: array
matchConditions:
Expand Down
50 changes: 30 additions & 20 deletions config/crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1864,8 +1864,10 @@ spec:
value:
description: |-
Value is a YAML string, single or multi-document, defining the resources to generate.
The namespace of each generated resource is taken from its rendered metadata.namespace,
resources without a namespace are treated as cluster-scoped.
The namespace of each generated resource is taken from its rendered metadata.namespace.
For cluster-scoped policies, resources without a namespace are treated as cluster-scoped.
For namespaced policies, resources without a namespace default to the policy's namespace,
and any other namespace is rejected.
minLength: 1
type: string
required:
Expand All @@ -1874,8 +1876,8 @@ spec:
type: object
x-kubernetes-validations:
- message: exactly one of expression or template must be set
rule: (has(self.expression) && !has(self.template)) || (!has(self.expression)
&& has(self.template))
rule: (has(self.expression) && self.expression != '' && !has(self.template))
|| ((!has(self.expression) || self.expression == '') && has(self.template))
minItems: 1
type: array
matchConditions:
Expand Down Expand Up @@ -2573,8 +2575,10 @@ spec:
value:
description: |-
Value is a YAML string, single or multi-document, defining the resources to generate.
The namespace of each generated resource is taken from its rendered metadata.namespace,
resources without a namespace are treated as cluster-scoped.
The namespace of each generated resource is taken from its rendered metadata.namespace.
For cluster-scoped policies, resources without a namespace are treated as cluster-scoped.
For namespaced policies, resources without a namespace default to the policy's namespace,
and any other namespace is rejected.
minLength: 1
type: string
required:
Expand All @@ -2583,8 +2587,8 @@ spec:
type: object
x-kubernetes-validations:
- message: exactly one of expression or template must be set
rule: (has(self.expression) && !has(self.template)) || (!has(self.expression)
&& has(self.template))
rule: (has(self.expression) && self.expression != '' && !has(self.template))
|| ((!has(self.expression) || self.expression == '') && has(self.template))
minItems: 1
type: array
matchConditions:
Expand Down Expand Up @@ -3281,8 +3285,10 @@ spec:
value:
description: |-
Value is a YAML string, single or multi-document, defining the resources to generate.
The namespace of each generated resource is taken from its rendered metadata.namespace,
resources without a namespace are treated as cluster-scoped.
The namespace of each generated resource is taken from its rendered metadata.namespace.
For cluster-scoped policies, resources without a namespace are treated as cluster-scoped.
For namespaced policies, resources without a namespace default to the policy's namespace,
and any other namespace is rejected.
minLength: 1
type: string
required:
Expand All @@ -3291,8 +3297,8 @@ spec:
type: object
x-kubernetes-validations:
- message: exactly one of expression or template must be set
rule: (has(self.expression) && !has(self.template)) || (!has(self.expression)
&& has(self.template))
rule: (has(self.expression) && self.expression != '' && !has(self.template))
|| ((!has(self.expression) || self.expression == '') && has(self.template))
minItems: 1
type: array
matchConditions:
Expand Down Expand Up @@ -19196,8 +19202,10 @@ spec:
value:
description: |-
Value is a YAML string, single or multi-document, defining the resources to generate.
The namespace of each generated resource is taken from its rendered metadata.namespace,
resources without a namespace are treated as cluster-scoped.
The namespace of each generated resource is taken from its rendered metadata.namespace.
For cluster-scoped policies, resources without a namespace are treated as cluster-scoped.
For namespaced policies, resources without a namespace default to the policy's namespace,
and any other namespace is rejected.
minLength: 1
type: string
required:
Expand All @@ -19206,8 +19214,8 @@ spec:
type: object
x-kubernetes-validations:
- message: exactly one of expression or template must be set
rule: (has(self.expression) && !has(self.template)) || (!has(self.expression)
&& has(self.template))
rule: (has(self.expression) && self.expression != '' && !has(self.template))
|| ((!has(self.expression) || self.expression == '') && has(self.template))
minItems: 1
type: array
matchConditions:
Expand Down Expand Up @@ -19906,8 +19914,10 @@ spec:
value:
description: |-
Value is a YAML string, single or multi-document, defining the resources to generate.
The namespace of each generated resource is taken from its rendered metadata.namespace,
resources without a namespace are treated as cluster-scoped.
The namespace of each generated resource is taken from its rendered metadata.namespace.
For cluster-scoped policies, resources without a namespace are treated as cluster-scoped.
For namespaced policies, resources without a namespace default to the policy's namespace,
and any other namespace is rejected.
minLength: 1
type: string
required:
Expand All @@ -19916,8 +19926,8 @@ spec:
type: object
x-kubernetes-validations:
- message: exactly one of expression or template must be set
rule: (has(self.expression) && !has(self.template)) || (!has(self.expression)
&& has(self.template))
rule: (has(self.expression) && self.expression != '' && !has(self.template))
|| ((!has(self.expression) || self.expression == '') && has(self.template))
minItems: 1
type: array
matchConditions:
Expand Down
Loading
Loading