Skip to content

Commit

Permalink
Fixed issue-5102: Show rule count and type in output (kyverno#5106)
Browse files Browse the repository at this point in the history
Signed-off-by: Pratik Shah <pratik@infracloud.io>

Signed-off-by: Pratik Shah <pratik@infracloud.io>
  • Loading branch information
shahpratikr authored Oct 27, 2022
1 parent cf2b8da commit 2c4a2da
Show file tree
Hide file tree
Showing 17 changed files with 905 additions and 15 deletions.
4 changes: 4 additions & 0 deletions api/kyverno/v1/clusterpolicy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ import (
// +kubebuilder:printcolumn:name="Failure Policy",type=string,JSONPath=".spec.failurePolicy",priority=1
// +kubebuilder:printcolumn:name="Ready",type=boolean,JSONPath=`.status.ready`
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
// +kubebuilder:printcolumn:name="Validate",type=integer,JSONPath=`.status.rulecount.validate`,priority=1
// +kubebuilder:printcolumn:name="Mutate",type=integer,JSONPath=`.status.rulecount.mutate`,priority=1
// +kubebuilder:printcolumn:name="Generate",type=integer,JSONPath=`.status.rulecount.generate`,priority=1
// +kubebuilder:printcolumn:name="Verifyimages",type=integer,JSONPath=`.status.rulecount.verifyimages`,priority=1
// +kubebuilder:storageversion

// ClusterPolicy declares validation, mutation, and generation behaviors for matching resources.
Expand Down
16 changes: 16 additions & 0 deletions api/kyverno/v1/policy_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,22 @@ type PolicyStatus struct {
// Autogen contains autogen status information
// +optional
Autogen AutogenStatus `json:"autogen" yaml:"autogen"`
// RuleCount describes total number of rules in a policy
// +optional
RuleCount RuleCountStatus `json:"rulecount" yaml:"rulecount"`
}

// RuleCountStatus contains four variables which describes counts for
// validate, generate, mutate and verify images rules
type RuleCountStatus struct {
// Count for validate rules in policy
Validate int `json:"validate" yaml:"validate"`
// Count for generate rules in policy
Generate int `json:"generate" yaml:"generate"`
// Count for mutate rules in policy
Mutate int `json:"mutate" yaml:"mutate"`
// Count for verify image rules in policy
VerifyImages int `json:"verifyimages" yaml:"verifyimages"`
}

func (status *PolicyStatus) SetReady(ready bool) {
Expand Down
4 changes: 4 additions & 0 deletions api/kyverno/v1/policy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ import (
// +kubebuilder:printcolumn:name="Failure Policy",type=string,JSONPath=".spec.failurePolicy",priority=1
// +kubebuilder:printcolumn:name="Ready",type=boolean,JSONPath=`.status.ready`
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
// +kubebuilder:printcolumn:name="Validate",type=integer,JSONPath=`.status.rulecount.validate`,priority=1
// +kubebuilder:printcolumn:name="Mutate",type=integer,JSONPath=`.status.rulecount.mutate`,priority=1
// +kubebuilder:printcolumn:name="Generate",type=integer,JSONPath=`.status.rulecount.generate`,priority=1
// +kubebuilder:printcolumn:name="Verifyimages",type=integer,JSONPath=`.status.rulecount.verifyimages`,priority=1
// +kubebuilder:resource:shortName=pol,categories=kyverno;all
// +kubebuilder:storageversion

Expand Down
16 changes: 16 additions & 0 deletions api/kyverno/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions api/kyverno/v2beta1/clusterpolicy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ import (
// +kubebuilder:printcolumn:name="Failure Policy",type=string,JSONPath=".spec.failurePolicy",priority=1
// +kubebuilder:printcolumn:name="Ready",type=boolean,JSONPath=`.status.ready`
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
// +kubebuilder:printcolumn:name="Validate",type=integer,JSONPath=`.status.rulecount.validate`,priority=1
// +kubebuilder:printcolumn:name="Mutate",type=integer,JSONPath=`.status.rulecount.mutate`,priority=1
// +kubebuilder:printcolumn:name="Generate",type=integer,JSONPath=`.status.rulecount.generate`,priority=1
// +kubebuilder:printcolumn:name="Verifyimages",type=integer,JSONPath=`.status.rulecount.verifyimages`,priority=1

// ClusterPolicy declares validation, mutation, and generation behaviors for matching resources.
type ClusterPolicy struct {
Expand Down
4 changes: 4 additions & 0 deletions api/kyverno/v2beta1/policy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ import (
// +kubebuilder:printcolumn:name="Failure Policy",type=string,JSONPath=".spec.failurePolicy",priority=1
// +kubebuilder:printcolumn:name="Ready",type=boolean,JSONPath=`.status.ready`
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
// +kubebuilder:printcolumn:name="Validate",type=integer,JSONPath=`.status.rulecount.validate`,priority=1
// +kubebuilder:printcolumn:name="Mutate",type=integer,JSONPath=`.status.rulecount.mutate`,priority=1
// +kubebuilder:printcolumn:name="Generate",type=integer,JSONPath=`.status.rulecount.generate`,priority=1
// +kubebuilder:printcolumn:name="Verifyimages",type=integer,JSONPath=`.status.rulecount.verifyimages`,priority=1
// +kubebuilder:resource:shortName=pol,categories=kyverno;all

// Policy declares validation, mutation, and generation behaviors for matching resources.
Expand Down
148 changes: 148 additions & 0 deletions charts/kyverno/templates/crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1029,6 +1029,22 @@ spec:
- jsonPath: .metadata.creationTimestamp
name: Age
type: date
- jsonPath: .status.rulecount.validate
name: Validate
priority: 1
type: integer
- jsonPath: .status.rulecount.mutate
name: Mutate
priority: 1
type: integer
- jsonPath: .status.rulecount.generate
name: Generate
priority: 1
type: integer
- jsonPath: .status.rulecount.verifyimages
name: Verifyimages
priority: 1
type: integer
name: v1
schema:
openAPIV3Schema:
Expand Down Expand Up @@ -4632,6 +4648,27 @@ spec:
ready:
description: Ready indicates if the policy is ready to serve the admission request. Deprecated in favor of Conditions
type: boolean
rulecount:
description: RuleCount describes total number of rules in a policy
properties:
generate:
description: Count for generate rules in policy
type: integer
mutate:
description: Count for mutate rules in policy
type: integer
validate:
description: Count for validate rules in policy
type: integer
verifyimages:
description: Count for verify image rules in policy
type: integer
required:
- generate
- mutate
- validate
- verifyimages
type: object
required:
- ready
type: object
Expand Down Expand Up @@ -4659,6 +4696,22 @@ spec:
- jsonPath: .metadata.creationTimestamp
name: Age
type: date
- jsonPath: .status.rulecount.validate
name: Validate
priority: 1
type: integer
- jsonPath: .status.rulecount.mutate
name: Mutate
priority: 1
type: integer
- jsonPath: .status.rulecount.generate
name: Generate
priority: 1
type: integer
- jsonPath: .status.rulecount.verifyimages
name: Verifyimages
priority: 1
type: integer
name: v2beta1
schema:
openAPIV3Schema:
Expand Down Expand Up @@ -8115,6 +8168,27 @@ spec:
ready:
description: Ready indicates if the policy is ready to serve the admission request. Deprecated in favor of Conditions
type: boolean
rulecount:
description: RuleCount describes total number of rules in a policy
properties:
generate:
description: Count for generate rules in policy
type: integer
mutate:
description: Count for mutate rules in policy
type: integer
validate:
description: Count for validate rules in policy
type: integer
verifyimages:
description: Count for verify image rules in policy
type: integer
required:
- generate
- mutate
- validate
- verifyimages
type: object
required:
- ready
type: object
Expand Down Expand Up @@ -8619,6 +8693,22 @@ spec:
- jsonPath: .metadata.creationTimestamp
name: Age
type: date
- jsonPath: .status.rulecount.validate
name: Validate
priority: 1
type: integer
- jsonPath: .status.rulecount.mutate
name: Mutate
priority: 1
type: integer
- jsonPath: .status.rulecount.generate
name: Generate
priority: 1
type: integer
- jsonPath: .status.rulecount.verifyimages
name: Verifyimages
priority: 1
type: integer
name: v1
schema:
openAPIV3Schema:
Expand Down Expand Up @@ -12222,6 +12312,27 @@ spec:
ready:
description: Ready indicates if the policy is ready to serve the admission request. Deprecated in favor of Conditions
type: boolean
rulecount:
description: RuleCount describes total number of rules in a policy
properties:
generate:
description: Count for generate rules in policy
type: integer
mutate:
description: Count for mutate rules in policy
type: integer
validate:
description: Count for validate rules in policy
type: integer
verifyimages:
description: Count for verify image rules in policy
type: integer
required:
- generate
- mutate
- validate
- verifyimages
type: object
required:
- ready
type: object
Expand Down Expand Up @@ -12249,6 +12360,22 @@ spec:
- jsonPath: .metadata.creationTimestamp
name: Age
type: date
- jsonPath: .status.rulecount.validate
name: Validate
priority: 1
type: integer
- jsonPath: .status.rulecount.mutate
name: Mutate
priority: 1
type: integer
- jsonPath: .status.rulecount.generate
name: Generate
priority: 1
type: integer
- jsonPath: .status.rulecount.verifyimages
name: Verifyimages
priority: 1
type: integer
name: v2beta1
schema:
openAPIV3Schema:
Expand Down Expand Up @@ -15705,6 +15832,27 @@ spec:
ready:
description: Ready indicates if the policy is ready to serve the admission request. Deprecated in favor of Conditions
type: boolean
rulecount:
description: RuleCount describes total number of rules in a policy
properties:
generate:
description: Count for generate rules in policy
type: integer
mutate:
description: Count for mutate rules in policy
type: integer
validate:
description: Count for validate rules in policy
type: integer
verifyimages:
description: Count for verify image rules in policy
type: integer
required:
- generate
- mutate
- validate
- verifyimages
type: object
required:
- ready
type: object
Expand Down
Loading

0 comments on commit 2c4a2da

Please sign in to comment.