From d19a44d34ceac8fc3e4ed4749b5bcb12fd022b28 Mon Sep 17 00:00:00 2001 From: Shuting Zhao Date: Tue, 3 Nov 2020 16:31:41 -0800 Subject: [PATCH] print fields failreAction and background for kyverno policy --- charts/kyverno/crds/crds.yaml | 20 ++++++++++++++++++++ definitions/crds/crds.yaml | 18 ++++++++++++++++++ definitions/install.yaml | 20 ++++++++++++++++++++ definitions/install_debug.yaml | 20 ++++++++++++++++++++ pkg/api/kyverno/v1/types.go | 4 ++-- 5 files changed, 80 insertions(+), 2 deletions(-) diff --git a/charts/kyverno/crds/crds.yaml b/charts/kyverno/crds/crds.yaml index 73ab81dbd7..d1a47ebb3f 100644 --- a/charts/kyverno/crds/crds.yaml +++ b/charts/kyverno/crds/crds.yaml @@ -3,6 +3,16 @@ kind: CustomResourceDefinition metadata: name: clusterpolicies.kyverno.io spec: + additionalPrinterColumns: + - JSONPath: .spec.background + description: Background provides choice for applying rules to existing resources. + name: Background + type: string + - JSONPath: .spec.validationFailureAction + description: ValidationFailureAction provides choice to enforce rules to resources + during policy application. + name: Validation FailureAction + type: string group: kyverno.io names: kind: ClusterPolicy @@ -414,6 +424,16 @@ kind: CustomResourceDefinition metadata: name: policies.kyverno.io spec: + additionalPrinterColumns: + - JSONPath: .spec.background + description: Background provides choice for applying rules to existing resources. + name: Background + type: string + - JSONPath: .spec.validationFailureAction + description: ValidationFailureAction provides choice to enforce rules to resources + during policy application. + name: Validation FailureAction + type: string group: kyverno.io names: kind: Policy diff --git a/definitions/crds/crds.yaml b/definitions/crds/crds.yaml index 4efe95fb44..5fb0ddeadf 100644 --- a/definitions/crds/crds.yaml +++ b/definitions/crds/crds.yaml @@ -3,6 +3,15 @@ kind: CustomResourceDefinition metadata: name: clusterpolicies.kyverno.io spec: + additionalPrinterColumns: + - JSONPath: .spec.background + description: Background provides choice for applying rules to existing resources. + name: Background + type: string + - JSONPath: .spec.validationFailureAction + description: ValidationFailureAction provides choice to enforce rules to resources during policy application. + name: Validation FailureAction + type: string group: kyverno.io versions: - name: v1 @@ -277,6 +286,15 @@ kind: CustomResourceDefinition metadata: name: policies.kyverno.io spec: + additionalPrinterColumns: + - JSONPath: .spec.background + description: Background provides choice for applying rules to existing resources. + name: Background + type: string + - JSONPath: .spec.validationFailureAction + description: ValidationFailureAction provides choice to enforce rules to resources during policy application. + name: Validation FailureAction + type: string group: kyverno.io versions: - name: v1 diff --git a/definitions/install.yaml b/definitions/install.yaml index 602893f8d7..6534b8eaf6 100644 --- a/definitions/install.yaml +++ b/definitions/install.yaml @@ -8,6 +8,16 @@ kind: CustomResourceDefinition metadata: name: clusterpolicies.kyverno.io spec: + additionalPrinterColumns: + - JSONPath: .spec.validationFailureAction + description: ValidationFailureAction provides choice to enforce rules to resources + during policy application. + name: Validation FailureAction + type: string + - JSONPath: .spec.background + description: Background provides choice for applying rules to existing resources. + name: Background + type: string group: kyverno.io names: kind: ClusterPolicy @@ -419,6 +429,16 @@ kind: CustomResourceDefinition metadata: name: policies.kyverno.io spec: + additionalPrinterColumns: + - JSONPath: .spec.validationFailureAction + description: ValidationFailureAction provides choice to enforce rules to resources + during policy application. + name: Validation FailureAction + type: string + - JSONPath: .spec.background + description: Background provides choice for applying rules to existing resources. + name: Background + type: string group: kyverno.io names: kind: Policy diff --git a/definitions/install_debug.yaml b/definitions/install_debug.yaml index 2a0971c5ae..5c9b0a97d1 100644 --- a/definitions/install_debug.yaml +++ b/definitions/install_debug.yaml @@ -8,6 +8,16 @@ kind: CustomResourceDefinition metadata: name: clusterpolicies.kyverno.io spec: + additionalPrinterColumns: + - JSONPath: .spec.background + description: Background provides choice for applying rules to existing resources. + name: Background + type: string + - JSONPath: .spec.validationFailureAction + description: ValidationFailureAction provides choice to enforce rules to resources + during policy application. + name: Validation FailureAction + type: string group: kyverno.io names: kind: ClusterPolicy @@ -419,6 +429,16 @@ kind: CustomResourceDefinition metadata: name: policies.kyverno.io spec: + additionalPrinterColumns: + - JSONPath: .spec.background + description: Background provides choice for applying rules to existing resources. + name: Background + type: string + - JSONPath: .spec.validationFailureAction + description: ValidationFailureAction provides choice to enforce rules to resources + during policy application. + name: Validation FailureAction + type: string group: kyverno.io names: kind: Policy diff --git a/pkg/api/kyverno/v1/types.go b/pkg/api/kyverno/v1/types.go index b55db92b88..0346920309 100644 --- a/pkg/api/kyverno/v1/types.go +++ b/pkg/api/kyverno/v1/types.go @@ -148,7 +148,7 @@ type Policy struct { type Spec struct { // Rules contains the list of rules to be applied to resources Rules []Rule `json:"rules,omitempty" yaml:"rules,omitempty"` - // ValidationFailureAction provides choice to enforce rules to resources during policy violations. + // ValidationFailureAction provides choice to enforce rules to resources during policy application. // Default value is "audit". ValidationFailureAction string `json:"validationFailureAction,omitempty" yaml:"validationFailureAction,omitempty"` // Background provides choice for applying rules to existing resources. @@ -193,7 +193,7 @@ type Rule struct { } type ContextEntry struct { - Name string `json:"name,omitempty" yaml:"name,omitempty"` + Name string `json:"name,omitempty" yaml:"name,omitempty"` ConfigMap *ConfigMapReference `json:"configMap,omitempty" yaml:"configMap,omitempty"` }