Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions api/policies.kyverno.io/v1alpha1/policy_exception.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ type PolicyRef struct {

// Kind is the kind of the policy
Kind string `json:"kind"`

// ValidationActions overrides the policy's validation actions when set
// +optional
ValidationActions []admissionregistrationv1.ValidationAction `json:"validationActions,omitempty"`
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need a list of actions?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've a question here, if the ValidatingPolicy ValidationAction is set to Deny and we create a policy exception with ValidationAction set to Audit to override. and we violate the policy rules:

  1. Will a policy violation log be written to the policy report?
  2. If yes (Because "Audit") what if we have in the policy exception, validationAction: Warn, Will Warn alone write a policy violation log to the policy report?

As if the Warn only will also write the log to the policy report I think it should be OK. but if not and we need an Audit, I think here we need to keep ValidationActions to be list so that we can use:

validationActions:
  - Audit
  - Warn

As we write it in traditional ways for ValidatingPolicy.

@realshuting can you confirm this with me?

Comment on lines +73 to +75
}

func (p *PolicyRef) Validate(path *field.Path) (errs field.ErrorList) {
Expand Down
9 changes: 8 additions & 1 deletion api/policies.kyverno.io/v1alpha1/zz_generated.deepcopy.go

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

Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,14 @@ spec:
name:
description: Name is the name of the policy
type: string
validationActions:
description: ValidationActions overrides the policy's validation
actions when set
items:
description: ValidationAction specifies a policy enforcement
action.
type: string
type: array
Comment on lines +119 to +121
required:
- kind
- name
Expand Down Expand Up @@ -229,6 +237,14 @@ spec:
name:
description: Name is the name of the policy
type: string
validationActions:
description: ValidationActions overrides the policy's validation
actions when set
items:
description: ValidationAction specifies a policy enforcement
action.
type: string
type: array
Comment on lines +245 to +247
required:
- kind
- name
Expand Down Expand Up @@ -346,6 +362,14 @@ spec:
name:
description: Name is the name of the policy
type: string
validationActions:
description: ValidationActions overrides the policy's validation
actions when set
items:
description: ValidationAction specifies a policy enforcement
action.
type: string
type: array
Comment on lines +370 to +372
required:
- kind
- name
Expand Down
24 changes: 24 additions & 0 deletions config/crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31721,6 +31721,14 @@ spec:
name:
description: Name is the name of the policy
type: string
validationActions:
description: ValidationActions overrides the policy's validation
actions when set
items:
description: ValidationAction specifies a policy enforcement
action.
type: string
type: array
Comment on lines +31724 to +31731
required:
- kind
- name
Expand Down Expand Up @@ -31839,6 +31847,14 @@ spec:
name:
description: Name is the name of the policy
type: string
validationActions:
description: ValidationActions overrides the policy's validation
actions when set
items:
description: ValidationAction specifies a policy enforcement
action.
type: string
type: array
Comment on lines +31850 to +31857
required:
- kind
- name
Expand Down Expand Up @@ -31956,6 +31972,14 @@ spec:
name:
description: Name is the name of the policy
type: string
validationActions:
description: ValidationActions overrides the policy's validation
actions when set
items:
description: ValidationAction specifies a policy enforcement
action.
type: string
type: array
Comment on lines +31975 to +31982
required:
- kind
- name
Expand Down
24 changes: 24 additions & 0 deletions config/crds/policies.kyverno.io_policyexceptions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,14 @@ spec:
name:
description: Name is the name of the policy
type: string
validationActions:
description: ValidationActions overrides the policy's validation
actions when set
items:
description: ValidationAction specifies a policy enforcement
action.
type: string
type: array
Comment on lines +117 to +119
required:
- kind
- name
Expand Down Expand Up @@ -227,6 +235,14 @@ spec:
name:
description: Name is the name of the policy
type: string
validationActions:
description: ValidationActions overrides the policy's validation
actions when set
items:
description: ValidationAction specifies a policy enforcement
action.
type: string
type: array
Comment on lines +243 to +245
required:
- kind
- name
Expand Down Expand Up @@ -344,6 +360,14 @@ spec:
name:
description: Name is the name of the policy
type: string
validationActions:
description: ValidationActions overrides the policy's validation
actions when set
items:
description: ValidationAction specifies a policy enforcement
action.
type: string
type: array
Comment on lines +368 to +370
required:
- kind
- name
Expand Down
14 changes: 14 additions & 0 deletions docs/user/crd/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6498,6 +6498,20 @@ <h3 id="policies.kyverno.io/v1alpha1.PolicyRef">PolicyRef
<p>Kind is the kind of the policy</p>
</td>
</tr>
<tr>
<td>
<code>validationActions</code><br/>
<em>
<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.35/#validationaction-v1-admissionregistration">
[]Kubernetes admissionregistration/v1.ValidationAction
</a>
</em>
</td>
<td>
<em>(Optional)</em>
<p>ValidationActions overrides the policy&rsquo;s validation actions when set</p>
</td>
</tr>
</tbody>
</table>
<hr />
Expand Down
29 changes: 29 additions & 0 deletions docs/user/crd/kyverno_cel_policies.v1alpha1.html
Original file line number Diff line number Diff line change
Expand Up @@ -8537,6 +8537,35 @@ <H3 id="policies-kyverno-io-v1alpha1-PolicyRef">PolicyRef
</tr>




<tr>
<td><code>validationActions</code>

</br>




<a href="https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.35/#validationaction-v1-admissionregistration">
<span style="font-family: monospace">[]admissionregistration/v1.ValidationAction</span>
</a>


</td>
<td>


<p>ValidationActions overrides the policy's validation actions when set</p>





</td>
</tr>




</tbody>
Expand Down