diff --git a/api/kyverno/v1/common_types.go b/api/kyverno/v1/common_types.go index e1e855089b..614d215de4 100644 --- a/api/kyverno/v1/common_types.go +++ b/api/kyverno/v1/common_types.go @@ -656,6 +656,11 @@ func (v *ForEachValidation) SetAnyPattern(in apiextensions.JSON) { // Generation defines how new resources should be created and managed. type Generation struct { + // GenerateExisting controls whether to trigger the rule in existing resources + // If is set to "true" the rule will be triggered and applied to existing matched resources. + // +optional + GenerateExisting *bool `json:"generateExisting,omitempty" yaml:"generateExisting,omitempty"` + // ResourceSpec contains information to select the resource. ResourceSpec `json:",omitempty" yaml:",omitempty"` @@ -690,6 +695,10 @@ type Generation struct { CloneList CloneList `json:"cloneList,omitempty" yaml:"cloneList,omitempty"` } +func (g *Generation) IsGenerateExisting() *bool { + return g.GenerateExisting +} + type CloneList struct { // Namespace specifies source resource namespace. Namespace string `json:"namespace,omitempty" yaml:"namespace,omitempty"` diff --git a/api/kyverno/v1/spec_types.go b/api/kyverno/v1/spec_types.go index d1d6f75d78..455cd17155 100644 --- a/api/kyverno/v1/spec_types.go +++ b/api/kyverno/v1/spec_types.go @@ -111,9 +111,7 @@ type Spec struct { // +optional GenerateExistingOnPolicyUpdate *bool `json:"generateExistingOnPolicyUpdate,omitempty" yaml:"generateExistingOnPolicyUpdate,omitempty"` - // GenerateExisting controls whether to trigger generate rule in existing resources - // If is set to "true" generate rule will be triggered and applied to existing matched resources. - // Defaults to "false" if not specified. + // Deprecated, use generateExisting under the generate rule instead // +optional GenerateExisting bool `json:"generateExisting,omitempty" yaml:"generateExisting,omitempty"` @@ -251,6 +249,14 @@ func (s *Spec) GetMutateExistingOnPolicyUpdate() bool { // IsGenerateExisting return GenerateExisting set value func (s *Spec) IsGenerateExisting() bool { + for _, rule := range s.Rules { + if rule.HasGenerate() { + isGenerateExisting := rule.Generation.IsGenerateExisting() + if isGenerateExisting != nil && *isGenerateExisting { + return true + } + } + } if s.GenerateExistingOnPolicyUpdate != nil && *s.GenerateExistingOnPolicyUpdate { return true } @@ -307,8 +313,15 @@ func (s *Spec) ValidateRules(path *field.Path, namespaced bool, policyNamespace } func (s *Spec) validateDeprecatedFields(path *field.Path) (errs field.ErrorList) { - if s.GenerateExistingOnPolicyUpdate != nil && s.GenerateExisting { - errs = append(errs, field.Forbidden(path.Child("generateExistingOnPolicyUpdate"), "remove the deprecated field and use generateExisting instead")) + for _, rule := range s.Rules { + if rule.HasGenerate() && rule.Generation.IsGenerateExisting() != nil { + if s.GenerateExistingOnPolicyUpdate != nil { + errs = append(errs, field.Forbidden(path.Child("generateExistingOnPolicyUpdate"), "remove the deprecated field and use spec.generate[*].generateExisting instead")) + } + if s.GenerateExisting { + errs = append(errs, field.Forbidden(path.Child("generateExisting"), "remove the deprecated field and use spec.generate[*].generateExisting instead")) + } + } } return errs } diff --git a/api/kyverno/v1/zz_generated.deepcopy.go b/api/kyverno/v1/zz_generated.deepcopy.go index 4dde45af8d..3158b65cbe 100755 --- a/api/kyverno/v1/zz_generated.deepcopy.go +++ b/api/kyverno/v1/zz_generated.deepcopy.go @@ -637,6 +637,11 @@ func (in *ForEachValidation) DeepCopy() *ForEachValidation { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Generation) DeepCopyInto(out *Generation) { *out = *in + if in.GenerateExisting != nil { + in, out := &in.GenerateExisting, &out.GenerateExisting + *out = new(bool) + **out = **in + } out.ResourceSpec = in.ResourceSpec if in.RawData != nil { in, out := &in.RawData, &out.RawData diff --git a/api/kyverno/v2beta1/spec_types.go b/api/kyverno/v2beta1/spec_types.go index 05854b02e7..7f42b32860 100644 --- a/api/kyverno/v2beta1/spec_types.go +++ b/api/kyverno/v2beta1/spec_types.go @@ -71,10 +71,7 @@ type Spec struct { // +optional GenerateExistingOnPolicyUpdate *bool `json:"generateExistingOnPolicyUpdate,omitempty" yaml:"generateExistingOnPolicyUpdate,omitempty"` - // GenerateExisting controls whether to trigger generate rule in existing resources - // If is set to "true" generate rule will be triggered and applied to existing matched resources. - // Defaults to "false" if not specified. - // +optional + // Deprecated, use generateExisting under the generate rule instead GenerateExisting bool `json:"generateExisting,omitempty" yaml:"generateExisting,omitempty"` // UseServerSideApply controls whether to use server-side apply for generate rules @@ -218,6 +215,14 @@ func (s *Spec) GetMutateExistingOnPolicyUpdate() bool { // IsGenerateExisting return GenerateExisting set value func (s *Spec) IsGenerateExisting() bool { + for _, rule := range s.Rules { + if rule.HasGenerate() { + isGenerateExisting := rule.Generation.IsGenerateExisting() + if isGenerateExisting != nil && *isGenerateExisting { + return true + } + } + } if s.GenerateExistingOnPolicyUpdate != nil && *s.GenerateExistingOnPolicyUpdate { return true } @@ -263,8 +268,15 @@ func (s *Spec) ValidateRules(path *field.Path, namespaced bool, policyNamespace } func (s *Spec) ValidateDeprecatedFields(path *field.Path) (errs field.ErrorList) { - if s.GenerateExistingOnPolicyUpdate != nil && s.GenerateExisting { - errs = append(errs, field.Forbidden(path.Child("generateExistingOnPolicyUpdate"), "remove the deprecated field and use generateExisting instead")) + for _, rule := range s.Rules { + if rule.HasGenerate() && rule.Generation.IsGenerateExisting() != nil { + if s.GenerateExistingOnPolicyUpdate != nil { + errs = append(errs, field.Forbidden(path.Child("generateExistingOnPolicyUpdate"), "remove the deprecated field and use spec.generate[*].generateExisting instead")) + } + if s.GenerateExisting { + errs = append(errs, field.Forbidden(path.Child("generateExisting"), "remove the deprecated field and use spec.generate[*].generateExisting instead")) + } + } } return errs } diff --git a/charts/kyverno/charts/crds/templates/kyverno.io/kyverno.io_clusterpolicies.yaml b/charts/kyverno/charts/crds/templates/kyverno.io/kyverno.io_clusterpolicies.yaml index a50699cfe9..731ff347a7 100644 --- a/charts/kyverno/charts/crds/templates/kyverno.io/kyverno.io_clusterpolicies.yaml +++ b/charts/kyverno/charts/crds/templates/kyverno.io/kyverno.io_clusterpolicies.yaml @@ -123,10 +123,8 @@ spec: - Fail type: string generateExisting: - description: |- - GenerateExisting controls whether to trigger generate rule in existing resources - If is set to "true" generate rule will be triggered and applied to existing matched resources. - Defaults to "false" if not specified. + description: Deprecated, use generateExisting under the generate rule + instead type: boolean generateExistingOnPolicyUpdate: description: Deprecated, use generateExisting instead @@ -1086,6 +1084,11 @@ spec: At most one of Data or Clone must be specified. If neither are provided, the generated resource will be created with default data only. x-kubernetes-preserve-unknown-fields: true + generateExisting: + description: |- + GenerateExisting controls whether to trigger the rule in existing resources + If is set to "true" the rule will be triggered and applied to existing matched resources. + type: boolean kind: description: Kind specifies resource kind. type: string @@ -5304,6 +5307,11 @@ spec: At most one of Data or Clone must be specified. If neither are provided, the generated resource will be created with default data only. x-kubernetes-preserve-unknown-fields: true + generateExisting: + description: |- + GenerateExisting controls whether to trigger the rule in existing resources + If is set to "true" the rule will be triggered and applied to existing matched resources. + type: boolean kind: description: Kind specifies resource kind. type: string @@ -8679,10 +8687,8 @@ spec: - Fail type: string generateExisting: - description: |- - GenerateExisting controls whether to trigger generate rule in existing resources - If is set to "true" generate rule will be triggered and applied to existing matched resources. - Defaults to "false" if not specified. + description: Deprecated, use generateExisting under the generate rule + instead type: boolean generateExistingOnPolicyUpdate: description: Deprecated, use generateExisting instead @@ -9440,6 +9446,11 @@ spec: At most one of Data or Clone must be specified. If neither are provided, the generated resource will be created with default data only. x-kubernetes-preserve-unknown-fields: true + generateExisting: + description: |- + GenerateExisting controls whether to trigger the rule in existing resources + If is set to "true" the rule will be triggered and applied to existing matched resources. + type: boolean kind: description: Kind specifies resource kind. type: string @@ -13606,6 +13617,11 @@ spec: At most one of Data or Clone must be specified. If neither are provided, the generated resource will be created with default data only. x-kubernetes-preserve-unknown-fields: true + generateExisting: + description: |- + GenerateExisting controls whether to trigger the rule in existing resources + If is set to "true" the rule will be triggered and applied to existing matched resources. + type: boolean kind: description: Kind specifies resource kind. type: string diff --git a/charts/kyverno/charts/crds/templates/kyverno.io/kyverno.io_policies.yaml b/charts/kyverno/charts/crds/templates/kyverno.io/kyverno.io_policies.yaml index b886cd89eb..a61d59113d 100644 --- a/charts/kyverno/charts/crds/templates/kyverno.io/kyverno.io_policies.yaml +++ b/charts/kyverno/charts/crds/templates/kyverno.io/kyverno.io_policies.yaml @@ -124,10 +124,8 @@ spec: - Fail type: string generateExisting: - description: |- - GenerateExisting controls whether to trigger generate rule in existing resources - If is set to "true" generate rule will be triggered and applied to existing matched resources. - Defaults to "false" if not specified. + description: Deprecated, use generateExisting under the generate rule + instead type: boolean generateExistingOnPolicyUpdate: description: Deprecated, use generateExisting instead @@ -1087,6 +1085,11 @@ spec: At most one of Data or Clone must be specified. If neither are provided, the generated resource will be created with default data only. x-kubernetes-preserve-unknown-fields: true + generateExisting: + description: |- + GenerateExisting controls whether to trigger the rule in existing resources + If is set to "true" the rule will be triggered and applied to existing matched resources. + type: boolean kind: description: Kind specifies resource kind. type: string @@ -5306,6 +5309,11 @@ spec: At most one of Data or Clone must be specified. If neither are provided, the generated resource will be created with default data only. x-kubernetes-preserve-unknown-fields: true + generateExisting: + description: |- + GenerateExisting controls whether to trigger the rule in existing resources + If is set to "true" the rule will be triggered and applied to existing matched resources. + type: boolean kind: description: Kind specifies resource kind. type: string @@ -8682,10 +8690,8 @@ spec: - Fail type: string generateExisting: - description: |- - GenerateExisting controls whether to trigger generate rule in existing resources - If is set to "true" generate rule will be triggered and applied to existing matched resources. - Defaults to "false" if not specified. + description: Deprecated, use generateExisting under the generate rule + instead type: boolean generateExistingOnPolicyUpdate: description: Deprecated, use generateExisting instead @@ -9443,6 +9449,11 @@ spec: At most one of Data or Clone must be specified. If neither are provided, the generated resource will be created with default data only. x-kubernetes-preserve-unknown-fields: true + generateExisting: + description: |- + GenerateExisting controls whether to trigger the rule in existing resources + If is set to "true" the rule will be triggered and applied to existing matched resources. + type: boolean kind: description: Kind specifies resource kind. type: string @@ -13609,6 +13620,11 @@ spec: At most one of Data or Clone must be specified. If neither are provided, the generated resource will be created with default data only. x-kubernetes-preserve-unknown-fields: true + generateExisting: + description: |- + GenerateExisting controls whether to trigger the rule in existing resources + If is set to "true" the rule will be triggered and applied to existing matched resources. + type: boolean kind: description: Kind specifies resource kind. type: string diff --git a/cmd/cli/kubectl-kyverno/data/crds/kyverno.io_clusterpolicies.yaml b/cmd/cli/kubectl-kyverno/data/crds/kyverno.io_clusterpolicies.yaml index b49b98970a..cd54d346b0 100644 --- a/cmd/cli/kubectl-kyverno/data/crds/kyverno.io_clusterpolicies.yaml +++ b/cmd/cli/kubectl-kyverno/data/crds/kyverno.io_clusterpolicies.yaml @@ -117,10 +117,8 @@ spec: - Fail type: string generateExisting: - description: |- - GenerateExisting controls whether to trigger generate rule in existing resources - If is set to "true" generate rule will be triggered and applied to existing matched resources. - Defaults to "false" if not specified. + description: Deprecated, use generateExisting under the generate rule + instead type: boolean generateExistingOnPolicyUpdate: description: Deprecated, use generateExisting instead @@ -1080,6 +1078,11 @@ spec: At most one of Data or Clone must be specified. If neither are provided, the generated resource will be created with default data only. x-kubernetes-preserve-unknown-fields: true + generateExisting: + description: |- + GenerateExisting controls whether to trigger the rule in existing resources + If is set to "true" the rule will be triggered and applied to existing matched resources. + type: boolean kind: description: Kind specifies resource kind. type: string @@ -5298,6 +5301,11 @@ spec: At most one of Data or Clone must be specified. If neither are provided, the generated resource will be created with default data only. x-kubernetes-preserve-unknown-fields: true + generateExisting: + description: |- + GenerateExisting controls whether to trigger the rule in existing resources + If is set to "true" the rule will be triggered and applied to existing matched resources. + type: boolean kind: description: Kind specifies resource kind. type: string @@ -8673,10 +8681,8 @@ spec: - Fail type: string generateExisting: - description: |- - GenerateExisting controls whether to trigger generate rule in existing resources - If is set to "true" generate rule will be triggered and applied to existing matched resources. - Defaults to "false" if not specified. + description: Deprecated, use generateExisting under the generate rule + instead type: boolean generateExistingOnPolicyUpdate: description: Deprecated, use generateExisting instead @@ -9434,6 +9440,11 @@ spec: At most one of Data or Clone must be specified. If neither are provided, the generated resource will be created with default data only. x-kubernetes-preserve-unknown-fields: true + generateExisting: + description: |- + GenerateExisting controls whether to trigger the rule in existing resources + If is set to "true" the rule will be triggered and applied to existing matched resources. + type: boolean kind: description: Kind specifies resource kind. type: string @@ -13600,6 +13611,11 @@ spec: At most one of Data or Clone must be specified. If neither are provided, the generated resource will be created with default data only. x-kubernetes-preserve-unknown-fields: true + generateExisting: + description: |- + GenerateExisting controls whether to trigger the rule in existing resources + If is set to "true" the rule will be triggered and applied to existing matched resources. + type: boolean kind: description: Kind specifies resource kind. type: string diff --git a/cmd/cli/kubectl-kyverno/data/crds/kyverno.io_policies.yaml b/cmd/cli/kubectl-kyverno/data/crds/kyverno.io_policies.yaml index 806be67b8b..4e4fc9eed2 100644 --- a/cmd/cli/kubectl-kyverno/data/crds/kyverno.io_policies.yaml +++ b/cmd/cli/kubectl-kyverno/data/crds/kyverno.io_policies.yaml @@ -118,10 +118,8 @@ spec: - Fail type: string generateExisting: - description: |- - GenerateExisting controls whether to trigger generate rule in existing resources - If is set to "true" generate rule will be triggered and applied to existing matched resources. - Defaults to "false" if not specified. + description: Deprecated, use generateExisting under the generate rule + instead type: boolean generateExistingOnPolicyUpdate: description: Deprecated, use generateExisting instead @@ -1081,6 +1079,11 @@ spec: At most one of Data or Clone must be specified. If neither are provided, the generated resource will be created with default data only. x-kubernetes-preserve-unknown-fields: true + generateExisting: + description: |- + GenerateExisting controls whether to trigger the rule in existing resources + If is set to "true" the rule will be triggered and applied to existing matched resources. + type: boolean kind: description: Kind specifies resource kind. type: string @@ -5300,6 +5303,11 @@ spec: At most one of Data or Clone must be specified. If neither are provided, the generated resource will be created with default data only. x-kubernetes-preserve-unknown-fields: true + generateExisting: + description: |- + GenerateExisting controls whether to trigger the rule in existing resources + If is set to "true" the rule will be triggered and applied to existing matched resources. + type: boolean kind: description: Kind specifies resource kind. type: string @@ -8676,10 +8684,8 @@ spec: - Fail type: string generateExisting: - description: |- - GenerateExisting controls whether to trigger generate rule in existing resources - If is set to "true" generate rule will be triggered and applied to existing matched resources. - Defaults to "false" if not specified. + description: Deprecated, use generateExisting under the generate rule + instead type: boolean generateExistingOnPolicyUpdate: description: Deprecated, use generateExisting instead @@ -9437,6 +9443,11 @@ spec: At most one of Data or Clone must be specified. If neither are provided, the generated resource will be created with default data only. x-kubernetes-preserve-unknown-fields: true + generateExisting: + description: |- + GenerateExisting controls whether to trigger the rule in existing resources + If is set to "true" the rule will be triggered and applied to existing matched resources. + type: boolean kind: description: Kind specifies resource kind. type: string @@ -13603,6 +13614,11 @@ spec: At most one of Data or Clone must be specified. If neither are provided, the generated resource will be created with default data only. x-kubernetes-preserve-unknown-fields: true + generateExisting: + description: |- + GenerateExisting controls whether to trigger the rule in existing resources + If is set to "true" the rule will be triggered and applied to existing matched resources. + type: boolean kind: description: Kind specifies resource kind. type: string diff --git a/config/crds/kyverno/kyverno.io_clusterpolicies.yaml b/config/crds/kyverno/kyverno.io_clusterpolicies.yaml index b49b98970a..cd54d346b0 100644 --- a/config/crds/kyverno/kyverno.io_clusterpolicies.yaml +++ b/config/crds/kyverno/kyverno.io_clusterpolicies.yaml @@ -117,10 +117,8 @@ spec: - Fail type: string generateExisting: - description: |- - GenerateExisting controls whether to trigger generate rule in existing resources - If is set to "true" generate rule will be triggered and applied to existing matched resources. - Defaults to "false" if not specified. + description: Deprecated, use generateExisting under the generate rule + instead type: boolean generateExistingOnPolicyUpdate: description: Deprecated, use generateExisting instead @@ -1080,6 +1078,11 @@ spec: At most one of Data or Clone must be specified. If neither are provided, the generated resource will be created with default data only. x-kubernetes-preserve-unknown-fields: true + generateExisting: + description: |- + GenerateExisting controls whether to trigger the rule in existing resources + If is set to "true" the rule will be triggered and applied to existing matched resources. + type: boolean kind: description: Kind specifies resource kind. type: string @@ -5298,6 +5301,11 @@ spec: At most one of Data or Clone must be specified. If neither are provided, the generated resource will be created with default data only. x-kubernetes-preserve-unknown-fields: true + generateExisting: + description: |- + GenerateExisting controls whether to trigger the rule in existing resources + If is set to "true" the rule will be triggered and applied to existing matched resources. + type: boolean kind: description: Kind specifies resource kind. type: string @@ -8673,10 +8681,8 @@ spec: - Fail type: string generateExisting: - description: |- - GenerateExisting controls whether to trigger generate rule in existing resources - If is set to "true" generate rule will be triggered and applied to existing matched resources. - Defaults to "false" if not specified. + description: Deprecated, use generateExisting under the generate rule + instead type: boolean generateExistingOnPolicyUpdate: description: Deprecated, use generateExisting instead @@ -9434,6 +9440,11 @@ spec: At most one of Data or Clone must be specified. If neither are provided, the generated resource will be created with default data only. x-kubernetes-preserve-unknown-fields: true + generateExisting: + description: |- + GenerateExisting controls whether to trigger the rule in existing resources + If is set to "true" the rule will be triggered and applied to existing matched resources. + type: boolean kind: description: Kind specifies resource kind. type: string @@ -13600,6 +13611,11 @@ spec: At most one of Data or Clone must be specified. If neither are provided, the generated resource will be created with default data only. x-kubernetes-preserve-unknown-fields: true + generateExisting: + description: |- + GenerateExisting controls whether to trigger the rule in existing resources + If is set to "true" the rule will be triggered and applied to existing matched resources. + type: boolean kind: description: Kind specifies resource kind. type: string diff --git a/config/crds/kyverno/kyverno.io_policies.yaml b/config/crds/kyverno/kyverno.io_policies.yaml index 806be67b8b..4e4fc9eed2 100644 --- a/config/crds/kyverno/kyverno.io_policies.yaml +++ b/config/crds/kyverno/kyverno.io_policies.yaml @@ -118,10 +118,8 @@ spec: - Fail type: string generateExisting: - description: |- - GenerateExisting controls whether to trigger generate rule in existing resources - If is set to "true" generate rule will be triggered and applied to existing matched resources. - Defaults to "false" if not specified. + description: Deprecated, use generateExisting under the generate rule + instead type: boolean generateExistingOnPolicyUpdate: description: Deprecated, use generateExisting instead @@ -1081,6 +1079,11 @@ spec: At most one of Data or Clone must be specified. If neither are provided, the generated resource will be created with default data only. x-kubernetes-preserve-unknown-fields: true + generateExisting: + description: |- + GenerateExisting controls whether to trigger the rule in existing resources + If is set to "true" the rule will be triggered and applied to existing matched resources. + type: boolean kind: description: Kind specifies resource kind. type: string @@ -5300,6 +5303,11 @@ spec: At most one of Data or Clone must be specified. If neither are provided, the generated resource will be created with default data only. x-kubernetes-preserve-unknown-fields: true + generateExisting: + description: |- + GenerateExisting controls whether to trigger the rule in existing resources + If is set to "true" the rule will be triggered and applied to existing matched resources. + type: boolean kind: description: Kind specifies resource kind. type: string @@ -8676,10 +8684,8 @@ spec: - Fail type: string generateExisting: - description: |- - GenerateExisting controls whether to trigger generate rule in existing resources - If is set to "true" generate rule will be triggered and applied to existing matched resources. - Defaults to "false" if not specified. + description: Deprecated, use generateExisting under the generate rule + instead type: boolean generateExistingOnPolicyUpdate: description: Deprecated, use generateExisting instead @@ -9437,6 +9443,11 @@ spec: At most one of Data or Clone must be specified. If neither are provided, the generated resource will be created with default data only. x-kubernetes-preserve-unknown-fields: true + generateExisting: + description: |- + GenerateExisting controls whether to trigger the rule in existing resources + If is set to "true" the rule will be triggered and applied to existing matched resources. + type: boolean kind: description: Kind specifies resource kind. type: string @@ -13603,6 +13614,11 @@ spec: At most one of Data or Clone must be specified. If neither are provided, the generated resource will be created with default data only. x-kubernetes-preserve-unknown-fields: true + generateExisting: + description: |- + GenerateExisting controls whether to trigger the rule in existing resources + If is set to "true" the rule will be triggered and applied to existing matched resources. + type: boolean kind: description: Kind specifies resource kind. type: string diff --git a/config/install-latest-testing.yaml b/config/install-latest-testing.yaml index efda0cd108..478f8adcc2 100644 --- a/config/install-latest-testing.yaml +++ b/config/install-latest-testing.yaml @@ -10324,10 +10324,8 @@ spec: - Fail type: string generateExisting: - description: |- - GenerateExisting controls whether to trigger generate rule in existing resources - If is set to "true" generate rule will be triggered and applied to existing matched resources. - Defaults to "false" if not specified. + description: Deprecated, use generateExisting under the generate rule + instead type: boolean generateExistingOnPolicyUpdate: description: Deprecated, use generateExisting instead @@ -11287,6 +11285,11 @@ spec: At most one of Data or Clone must be specified. If neither are provided, the generated resource will be created with default data only. x-kubernetes-preserve-unknown-fields: true + generateExisting: + description: |- + GenerateExisting controls whether to trigger the rule in existing resources + If is set to "true" the rule will be triggered and applied to existing matched resources. + type: boolean kind: description: Kind specifies resource kind. type: string @@ -15505,6 +15508,11 @@ spec: At most one of Data or Clone must be specified. If neither are provided, the generated resource will be created with default data only. x-kubernetes-preserve-unknown-fields: true + generateExisting: + description: |- + GenerateExisting controls whether to trigger the rule in existing resources + If is set to "true" the rule will be triggered and applied to existing matched resources. + type: boolean kind: description: Kind specifies resource kind. type: string @@ -18880,10 +18888,8 @@ spec: - Fail type: string generateExisting: - description: |- - GenerateExisting controls whether to trigger generate rule in existing resources - If is set to "true" generate rule will be triggered and applied to existing matched resources. - Defaults to "false" if not specified. + description: Deprecated, use generateExisting under the generate rule + instead type: boolean generateExistingOnPolicyUpdate: description: Deprecated, use generateExisting instead @@ -19641,6 +19647,11 @@ spec: At most one of Data or Clone must be specified. If neither are provided, the generated resource will be created with default data only. x-kubernetes-preserve-unknown-fields: true + generateExisting: + description: |- + GenerateExisting controls whether to trigger the rule in existing resources + If is set to "true" the rule will be triggered and applied to existing matched resources. + type: boolean kind: description: Kind specifies resource kind. type: string @@ -23807,6 +23818,11 @@ spec: At most one of Data or Clone must be specified. If neither are provided, the generated resource will be created with default data only. x-kubernetes-preserve-unknown-fields: true + generateExisting: + description: |- + GenerateExisting controls whether to trigger the rule in existing resources + If is set to "true" the rule will be triggered and applied to existing matched resources. + type: boolean kind: description: Kind specifies resource kind. type: string @@ -27465,10 +27481,8 @@ spec: - Fail type: string generateExisting: - description: |- - GenerateExisting controls whether to trigger generate rule in existing resources - If is set to "true" generate rule will be triggered and applied to existing matched resources. - Defaults to "false" if not specified. + description: Deprecated, use generateExisting under the generate rule + instead type: boolean generateExistingOnPolicyUpdate: description: Deprecated, use generateExisting instead @@ -28428,6 +28442,11 @@ spec: At most one of Data or Clone must be specified. If neither are provided, the generated resource will be created with default data only. x-kubernetes-preserve-unknown-fields: true + generateExisting: + description: |- + GenerateExisting controls whether to trigger the rule in existing resources + If is set to "true" the rule will be triggered and applied to existing matched resources. + type: boolean kind: description: Kind specifies resource kind. type: string @@ -32647,6 +32666,11 @@ spec: At most one of Data or Clone must be specified. If neither are provided, the generated resource will be created with default data only. x-kubernetes-preserve-unknown-fields: true + generateExisting: + description: |- + GenerateExisting controls whether to trigger the rule in existing resources + If is set to "true" the rule will be triggered and applied to existing matched resources. + type: boolean kind: description: Kind specifies resource kind. type: string @@ -36023,10 +36047,8 @@ spec: - Fail type: string generateExisting: - description: |- - GenerateExisting controls whether to trigger generate rule in existing resources - If is set to "true" generate rule will be triggered and applied to existing matched resources. - Defaults to "false" if not specified. + description: Deprecated, use generateExisting under the generate rule + instead type: boolean generateExistingOnPolicyUpdate: description: Deprecated, use generateExisting instead @@ -36784,6 +36806,11 @@ spec: At most one of Data or Clone must be specified. If neither are provided, the generated resource will be created with default data only. x-kubernetes-preserve-unknown-fields: true + generateExisting: + description: |- + GenerateExisting controls whether to trigger the rule in existing resources + If is set to "true" the rule will be triggered and applied to existing matched resources. + type: boolean kind: description: Kind specifies resource kind. type: string @@ -40950,6 +40977,11 @@ spec: At most one of Data or Clone must be specified. If neither are provided, the generated resource will be created with default data only. x-kubernetes-preserve-unknown-fields: true + generateExisting: + description: |- + GenerateExisting controls whether to trigger the rule in existing resources + If is set to "true" the rule will be triggered and applied to existing matched resources. + type: boolean kind: description: Kind specifies resource kind. type: string diff --git a/docs/user/crd/index.html b/docs/user/crd/index.html index 7aedc87e4c..4e139f030d 100644 --- a/docs/user/crd/index.html +++ b/docs/user/crd/index.html @@ -274,9 +274,7 @@ bool (Optional) -

GenerateExisting controls whether to trigger generate rule in existing resources -If is set to “true” generate rule will be triggered and applied to existing matched resources. -Defaults to “false” if not specified.

+

Deprecated, use generateExisting under the generate rule instead

@@ -552,9 +550,7 @@ bool (Optional) -

GenerateExisting controls whether to trigger generate rule in existing resources -If is set to “true” generate rule will be triggered and applied to existing matched resources. -Defaults to “false” if not specified.

+

Deprecated, use generateExisting under the generate rule instead

@@ -1932,6 +1928,19 @@ Kubernetes apiextensions/v1.JSON +generateExisting
+ +bool + + + +(Optional) +

GenerateExisting controls whether to trigger the rule in existing resources +If is set to “true” the rule will be triggered and applied to existing matched resources.

+ + + + ResourceSpec
@@ -4046,9 +4055,7 @@ bool (Optional) -

GenerateExisting controls whether to trigger generate rule in existing resources -If is set to “true” generate rule will be triggered and applied to existing matched resources. -Defaults to “false” if not specified.

+

Deprecated, use generateExisting under the generate rule instead

@@ -8809,10 +8816,7 @@ bool
-(Optional) -

GenerateExisting controls whether to trigger generate rule in existing resources -If is set to “true” generate rule will be triggered and applied to existing matched resources. -Defaults to “false” if not specified.

+

Deprecated, use generateExisting under the generate rule instead

@@ -9086,10 +9090,7 @@ bool -(Optional) -

GenerateExisting controls whether to trigger generate rule in existing resources -If is set to “true” generate rule will be triggered and applied to existing matched resources. -Defaults to “false” if not specified.

+

Deprecated, use generateExisting under the generate rule instead

@@ -10483,10 +10484,7 @@ bool -(Optional) -

GenerateExisting controls whether to trigger generate rule in existing resources -If is set to “true” generate rule will be triggered and applied to existing matched resources. -Defaults to “false” if not specified.

+

Deprecated, use generateExisting under the generate rule instead

diff --git a/docs/user/crd/kyverno.v1.html b/docs/user/crd/kyverno.v1.html index f82450b730..e305446a1a 100644 --- a/docs/user/crd/kyverno.v1.html +++ b/docs/user/crd/kyverno.v1.html @@ -482,9 +482,7 @@ Default value is "false".

-

GenerateExisting controls whether to trigger generate rule in existing resources -If is set to "true" generate rule will be triggered and applied to existing matched resources. -Defaults to "false" if not specified.

+

Deprecated, use generateExisting under the generate rule instead

@@ -1046,9 +1044,7 @@ Default value is "false".

-

GenerateExisting controls whether to trigger generate rule in existing resources -If is set to "true" generate rule will be triggered and applied to existing matched resources. -Defaults to "false" if not specified.

+

Deprecated, use generateExisting under the generate rule instead

@@ -3878,6 +3874,34 @@ must be satisfied for the validation rule to succeed.

+ + generateExisting + +
+ + + + + bool + + + + + + +

GenerateExisting controls whether to trigger the rule in existing resources +If is set to "true" the rule will be triggered and applied to existing matched resources.

+ + + + + + + + + + + ResourceSpec @@ -8004,9 +8028,7 @@ Default value is "false".

-

GenerateExisting controls whether to trigger generate rule in existing resources -If is set to "true" generate rule will be triggered and applied to existing matched resources. -Defaults to "false" if not specified.

+

Deprecated, use generateExisting under the generate rule instead

diff --git a/docs/user/crd/kyverno.v2beta1.html b/docs/user/crd/kyverno.v2beta1.html index 4ef88fc240..4d964d7478 100644 --- a/docs/user/crd/kyverno.v2beta1.html +++ b/docs/user/crd/kyverno.v2beta1.html @@ -1069,6 +1069,8 @@ Default value is "false".

generateExisting + * +
@@ -1081,9 +1083,7 @@ Default value is "false".

-

GenerateExisting controls whether to trigger generate rule in existing resources -If is set to "true" generate rule will be triggered and applied to existing matched resources. -Defaults to "false" if not specified.

+

Deprecated, use generateExisting under the generate rule instead

@@ -1632,6 +1632,8 @@ Default value is "false".

generateExisting + * +
@@ -1644,9 +1646,7 @@ Default value is "false".

-

GenerateExisting controls whether to trigger generate rule in existing resources -If is set to "true" generate rule will be triggered and applied to existing matched resources. -Defaults to "false" if not specified.

+

Deprecated, use generateExisting under the generate rule instead

@@ -4412,6 +4412,8 @@ Default value is "false".

generateExisting + * +
@@ -4424,9 +4426,7 @@ Default value is "false".

-

GenerateExisting controls whether to trigger generate rule in existing resources -If is set to "true" generate rule will be triggered and applied to existing matched resources. -Defaults to "false" if not specified.

+

Deprecated, use generateExisting under the generate rule instead

diff --git a/pkg/client/applyconfigurations/kyverno/v1/generation.go b/pkg/client/applyconfigurations/kyverno/v1/generation.go index 27d5e543a8..86c234baa3 100644 --- a/pkg/client/applyconfigurations/kyverno/v1/generation.go +++ b/pkg/client/applyconfigurations/kyverno/v1/generation.go @@ -26,6 +26,7 @@ import ( // GenerationApplyConfiguration represents an declarative configuration of the Generation type for use // with apply. type GenerationApplyConfiguration struct { + GenerateExisting *bool `json:"generateExisting,omitempty"` *ResourceSpecApplyConfiguration `json:"ResourceSpec,omitempty"` Synchronize *bool `json:"synchronize,omitempty"` OrphanDownstreamOnPolicyDelete *bool `json:"orphanDownstreamOnPolicyDelete,omitempty"` @@ -40,6 +41,14 @@ func Generation() *GenerationApplyConfiguration { return &GenerationApplyConfiguration{} } +// WithGenerateExisting sets the GenerateExisting field in the declarative configuration to the given value +// and returns the receiver, so that objects can be built by chaining "With" function invocations. +// If called multiple times, the GenerateExisting field is set to the value of the last call. +func (b *GenerationApplyConfiguration) WithGenerateExisting(value bool) *GenerationApplyConfiguration { + b.GenerateExisting = &value + return b +} + // WithAPIVersion sets the APIVersion field in the declarative configuration to the given value // and returns the receiver, so that objects can be built by chaining "With" function invocations. // If called multiple times, the APIVersion field is set to the value of the last call.