From 75e300799a2de1aa09a427b7109c1dadb61cd289 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charles-Edouard=20Br=C3=A9t=C3=A9ch=C3=A9?= Date: Thu, 28 Apr 2022 08:05:13 +0200 Subject: [PATCH] fix: remove unused type TargetMutation (#3706) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Charles-Edouard Brétéché Co-authored-by: Vyankatesh Kudtarkar --- api/kyverno/v1/common_types.go | 8 +---- api/kyverno/v1/zz_generated.deepcopy.go | 18 +--------- charts/kyverno/templates/crds.yaml | 4 +++ config/crds/kyverno.io_clusterpolicies.yaml | 4 +++ config/crds/kyverno.io_policies.yaml | 4 +++ config/install.yaml | 8 +++++ config/install_debug.yaml | 8 +++++ docs/crd/v1/index.html | 39 ++------------------- pkg/engine/loadtargets.go | 2 +- 9 files changed, 34 insertions(+), 61 deletions(-) diff --git a/api/kyverno/v1/common_types.go b/api/kyverno/v1/common_types.go index 64a2e644b5..6339faa7b8 100755 --- a/api/kyverno/v1/common_types.go +++ b/api/kyverno/v1/common_types.go @@ -225,7 +225,7 @@ type Mutation struct { // Targets defines the target resources to be mutated. // +optional - Targets []TargetMutation `json:"targets,omitempty" yaml:"targets,omitempty"` + Targets []ResourceSpec `json:"targets,omitempty" yaml:"targets,omitempty"` // PatchStrategicMerge is a strategic merge patch used to modify resources. // See https://kubernetes.io/docs/tasks/manage-kubernetes-objects/update-api-object-kubectl-patch/ @@ -243,12 +243,6 @@ type Mutation struct { ForEachMutation []ForEachMutation `json:"foreach,omitempty" yaml:"foreach,omitempty"` } -type TargetMutation struct { - // ResourceSpec specifies the target resource information. - // +optional - ResourceSpec `json:",omitempty" yaml:",omitempty"` -} - func (m *Mutation) GetPatchStrategicMerge() apiextensions.JSON { return FromJSON(m.RawPatchStrategicMerge) } diff --git a/api/kyverno/v1/zz_generated.deepcopy.go b/api/kyverno/v1/zz_generated.deepcopy.go index 77990803a8..471981f14f 100755 --- a/api/kyverno/v1/zz_generated.deepcopy.go +++ b/api/kyverno/v1/zz_generated.deepcopy.go @@ -742,7 +742,7 @@ func (in *Mutation) DeepCopyInto(out *Mutation) { *out = *in if in.Targets != nil { in, out := &in.Targets, &out.Targets - *out = make([]TargetMutation, len(*in)) + *out = make([]ResourceSpec, len(*in)) copy(*out, *in) } if in.RawPatchStrategicMerge != nil { @@ -1106,22 +1106,6 @@ func (in *StaticKeyAttestor) DeepCopy() *StaticKeyAttestor { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *TargetMutation) DeepCopyInto(out *TargetMutation) { - *out = *in - out.ResourceSpec = in.ResourceSpec -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TargetMutation. -func (in *TargetMutation) DeepCopy() *TargetMutation { - if in == nil { - return nil - } - out := new(TargetMutation) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *UserInfo) DeepCopyInto(out *UserInfo) { *out = *in diff --git a/charts/kyverno/templates/crds.yaml b/charts/kyverno/templates/crds.yaml index a89b6e02dc..680391083f 100644 --- a/charts/kyverno/templates/crds.yaml +++ b/charts/kyverno/templates/crds.yaml @@ -1094,6 +1094,7 @@ spec: targets: description: Targets defines the target resources to be mutated. items: + description: ResourceSpec contains information to identify a resource. properties: apiVersion: description: APIVersion specifies resource apiVersion. @@ -2630,6 +2631,7 @@ spec: targets: description: Targets defines the target resources to be mutated. items: + description: ResourceSpec contains information to identify a resource. properties: apiVersion: description: APIVersion specifies resource apiVersion. @@ -4877,6 +4879,7 @@ spec: targets: description: Targets defines the target resources to be mutated. items: + description: ResourceSpec contains information to identify a resource. properties: apiVersion: description: APIVersion specifies resource apiVersion. @@ -6413,6 +6416,7 @@ spec: targets: description: Targets defines the target resources to be mutated. items: + description: ResourceSpec contains information to identify a resource. properties: apiVersion: description: APIVersion specifies resource apiVersion. diff --git a/config/crds/kyverno.io_clusterpolicies.yaml b/config/crds/kyverno.io_clusterpolicies.yaml index 93b562e6af..c2cfdce3bd 100644 --- a/config/crds/kyverno.io_clusterpolicies.yaml +++ b/config/crds/kyverno.io_clusterpolicies.yaml @@ -1751,6 +1751,8 @@ spec: description: Targets defines the target resources to be mutated. items: + description: ResourceSpec contains information to identify + a resource. properties: apiVersion: description: APIVersion specifies resource apiVersion. @@ -4226,6 +4228,8 @@ spec: description: Targets defines the target resources to be mutated. items: + description: ResourceSpec contains information to identify + a resource. properties: apiVersion: description: APIVersion specifies resource apiVersion. diff --git a/config/crds/kyverno.io_policies.yaml b/config/crds/kyverno.io_policies.yaml index f1ca108fa2..21cf364e19 100644 --- a/config/crds/kyverno.io_policies.yaml +++ b/config/crds/kyverno.io_policies.yaml @@ -1752,6 +1752,8 @@ spec: description: Targets defines the target resources to be mutated. items: + description: ResourceSpec contains information to identify + a resource. properties: apiVersion: description: APIVersion specifies resource apiVersion. @@ -4228,6 +4230,8 @@ spec: description: Targets defines the target resources to be mutated. items: + description: ResourceSpec contains information to identify + a resource. properties: apiVersion: description: APIVersion specifies resource apiVersion. diff --git a/config/install.yaml b/config/install.yaml index 075b3fb524..f5d5afb328 100644 --- a/config/install.yaml +++ b/config/install.yaml @@ -1768,6 +1768,8 @@ spec: description: Targets defines the target resources to be mutated. items: + description: ResourceSpec contains information to identify + a resource. properties: apiVersion: description: APIVersion specifies resource apiVersion. @@ -4243,6 +4245,8 @@ spec: description: Targets defines the target resources to be mutated. items: + description: ResourceSpec contains information to identify + a resource. properties: apiVersion: description: APIVersion specifies resource apiVersion. @@ -7608,6 +7612,8 @@ spec: description: Targets defines the target resources to be mutated. items: + description: ResourceSpec contains information to identify + a resource. properties: apiVersion: description: APIVersion specifies resource apiVersion. @@ -10084,6 +10090,8 @@ spec: description: Targets defines the target resources to be mutated. items: + description: ResourceSpec contains information to identify + a resource. properties: apiVersion: description: APIVersion specifies resource apiVersion. diff --git a/config/install_debug.yaml b/config/install_debug.yaml index c9bcbf55ad..76ce7dedc2 100755 --- a/config/install_debug.yaml +++ b/config/install_debug.yaml @@ -1757,6 +1757,8 @@ spec: description: Targets defines the target resources to be mutated. items: + description: ResourceSpec contains information to identify + a resource. properties: apiVersion: description: APIVersion specifies resource apiVersion. @@ -4232,6 +4234,8 @@ spec: description: Targets defines the target resources to be mutated. items: + description: ResourceSpec contains information to identify + a resource. properties: apiVersion: description: APIVersion specifies resource apiVersion. @@ -7573,6 +7577,8 @@ spec: description: Targets defines the target resources to be mutated. items: + description: ResourceSpec contains information to identify + a resource. properties: apiVersion: description: APIVersion specifies resource apiVersion. @@ -10049,6 +10055,8 @@ spec: description: Targets defines the target resources to be mutated. items: + description: ResourceSpec contains information to identify + a resource. properties: apiVersion: description: APIVersion specifies resource apiVersion. diff --git a/docs/crd/v1/index.html b/docs/crd/v1/index.html index f1187ab520..3ff978369c 100644 --- a/docs/crd/v1/index.html +++ b/docs/crd/v1/index.html @@ -1879,8 +1879,8 @@ Optional. Defaults to “false” if not specified.

targets
- -[]TargetMutation + +[]ResourceSpec @@ -2418,7 +2418,7 @@ ResourceDescription GenerateRequestSpec, GenerateRequestStatus, Generation, -TargetMutation) +Mutation)

ResourceSpec contains information to identify a resource.

@@ -2826,39 +2826,6 @@ If not provided, the system roots are used.


-

TargetMutation -

-

-(Appears on: -Mutation) -

-

-

- - - - - - - - - - - - - -
FieldDescription
-ResourceSpec
- - -ResourceSpec - - -
-(Optional) -

ResourceSpec specifies the target resource information.

-
-

UserInfo

diff --git a/pkg/engine/loadtargets.go b/pkg/engine/loadtargets.go index f06bdaafd6..0dcaf49aa3 100644 --- a/pkg/engine/loadtargets.go +++ b/pkg/engine/loadtargets.go @@ -10,7 +10,7 @@ import ( "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" ) -func loadTargets(logger logr.Logger, targets []kyverno.TargetMutation, ctx *PolicyContext) ([]unstructured.Unstructured, error) { +func loadTargets(logger logr.Logger, targets []kyverno.ResourceSpec, ctx *PolicyContext) ([]unstructured.Unstructured, error) { targetObjects := make([]unstructured.Unstructured, len(targets)) var errors []error