diff --git a/definitions/install.yaml b/definitions/install.yaml index c226a64d84..c7da8e58ee 100644 --- a/definitions/install.yaml +++ b/definitions/install.yaml @@ -232,15 +232,13 @@ spec: type: string managedResource: type: object - required: - - kind properties: kind: type: string namespace: type: string creationBlocked: - type: bool + type: boolean --- kind: Namespace apiVersion: v1 diff --git a/definitions/install_debug.yaml b/definitions/install_debug.yaml index 53cfe0ca68..1c183251ab 100644 --- a/definitions/install_debug.yaml +++ b/definitions/install_debug.yaml @@ -232,15 +232,14 @@ spec: type: string managedResource: type: object - required: - - kind properties: kind: type: string namespace: type: string creationBlocked: - type: bool + type: boolean +--- apiVersion: v1 kind: ConfigMap metadata: diff --git a/pkg/api/kyverno/v1alpha1/types.go b/pkg/api/kyverno/v1alpha1/types.go index 7766612876..2d6a31e9a2 100644 --- a/pkg/api/kyverno/v1alpha1/types.go +++ b/pkg/api/kyverno/v1alpha1/types.go @@ -173,13 +173,13 @@ type ResourceSpec struct { // ViolatedRule stores the information regarding the rule type ViolatedRule struct { - Name string `json:"name"` - Type string `json:"type"` - Message string `json:"message"` - ManagedResource ManagedResource `json:"managedResource,omitempty"` + Name string `json:"name"` + Type string `json:"type"` + Message string `json:"message"` + ManagedResource ManagedResourceSpec `json:"managedResource,omitempty"` } -type ManagedResource struct { +type ManagedResourceSpec struct { Kind string `json:"kind,omitempty"` Namespace string `json:"namespace,omitempty"` CreationBlocked bool `json:"creationBlocked,omitempty"` diff --git a/pkg/api/kyverno/v1alpha1/zz_generated.deepcopy.go b/pkg/api/kyverno/v1alpha1/zz_generated.deepcopy.go index ba06870ad8..debd1e0789 100644 --- a/pkg/api/kyverno/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/api/kyverno/v1alpha1/zz_generated.deepcopy.go @@ -191,17 +191,17 @@ func (in *Generation) DeepCopy() *Generation { } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ManagedResource) DeepCopyInto(out *ManagedResource) { +func (in *ManagedResourceSpec) DeepCopyInto(out *ManagedResourceSpec) { *out = *in return } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ManagedResource. -func (in *ManagedResource) DeepCopy() *ManagedResource { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ManagedResourceSpec. +func (in *ManagedResourceSpec) DeepCopy() *ManagedResourceSpec { if in == nil { return nil } - out := new(ManagedResource) + out := new(ManagedResourceSpec) in.DeepCopyInto(out) return out } diff --git a/pkg/policyviolation/controller.go b/pkg/policyviolation/controller.go index 0175b64dd3..deeee4d5f1 100644 --- a/pkg/policyviolation/controller.go +++ b/pkg/policyviolation/controller.go @@ -259,7 +259,7 @@ func (pvc *PolicyViolationController) syncActiveResource(curPv *kyverno.ClusterP // when rejected resource created in the cluster func (pvc *PolicyViolationController) syncBlockedResource(curPv *kyverno.ClusterPolicyViolation) error { for _, violatedRule := range curPv.Spec.ViolatedRules { - if reflect.DeepEqual(violatedRule.ManagedResource, kyverno.ManagedResource{}) { + if reflect.DeepEqual(violatedRule.ManagedResource, kyverno.ManagedResourceSpec{}) { continue } diff --git a/pkg/policyviolation/helpers.go b/pkg/policyviolation/helpers.go index c41a737cac..4191686a97 100644 --- a/pkg/policyviolation/helpers.go +++ b/pkg/policyviolation/helpers.go @@ -248,7 +248,7 @@ func getOwners(dclient *dclient.Client, unstr unstructured.Unstructured) []pvRes func newViolatedRules(er engine.EngineResponse, msg string) (violatedRules []kyverno.ViolatedRule) { unstr := er.PatchedResource - dependant := kyverno.ManagedResource{ + dependant := kyverno.ManagedResourceSpec{ Kind: unstr.GetKind(), Namespace: unstr.GetNamespace(), CreationBlocked: true,