New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/foreach validate #2443
Merged
JimBugwadia
merged 20 commits into
kyverno:main
from
JimBugwadia:feature/foreach_validate
Oct 4, 2021
Merged
Feature/foreach validate #2443
JimBugwadia
merged 20 commits into
kyverno:main
from
JimBugwadia:feature/foreach_validate
Oct 4, 2021
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Signed-off-by: Jim Bugwadia <jim@nirmata.com>
Signed-off-by: Jim Bugwadia <jim@nirmata.com>
Signed-off-by: Jim Bugwadia <jim@nirmata.com>
Signed-off-by: Jim Bugwadia <jim@nirmata.com>
Signed-off-by: Jim Bugwadia <jim@nirmata.com>
Signed-off-by: Jim Bugwadia <jim@nirmata.com>
Signed-off-by: Jim Bugwadia <jim@nirmata.com>
Signed-off-by: Jim Bugwadia <jim@nirmata.com>
Signed-off-by: Jim Bugwadia <jim@nirmata.com>
Signed-off-by: Jim Bugwadia <jim@nirmata.com>
Signed-off-by: Jim Bugwadia <jim@nirmata.com>
Signed-off-by: Jim Bugwadia <jim@nirmata.com>
Signed-off-by: Jim Bugwadia <jim@nirmata.com>
Here is a sample policy for testing: apiVersion : kyverno.io/v1
kind: ClusterPolicy
metadata:
name: check-containers
spec:
validationFailureAction: enforce
background: false
rules:
- name: check-names
match:
resources:
kinds:
- Pod
preconditions:
- key: "{{request.type}}"
operator: NotEquals
value: "DELETE"
validate:
message: "Container names must contain the suffix '-valid'"
foreach:
list: "request.object.spec.containers"
pattern:
name: "*-valid" With this policy configured, here are some tests to show it executing: λ kubectl run nginx --image=nginx
Error from server: admission webhook "validate.kyverno.svc" denied the request:
resource Pod/default/nginx was blocked due to the following policies
check-containers:
check-names: 'validation failed in foreach rule for validation error: Container
names must contain the suffix ''-valid''. Rule check-names failed at path /name/' λ kubectl run nginx-valid --image=nginx
pod/nginx-valid created |
realshuting
approved these changes
Oct 4, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JimBugwadia - looks good, but the CLI test keeps failing without a specific error message. Does it pass for you locally?
Signed-off-by: Jim Bugwadia <jim@nirmata.com>
Signed-off-by: Jim Bugwadia <jim@nirmata.com>
Signed-off-by: Jim Bugwadia <jim@nirmata.com>
Signed-off-by: Jim Bugwadia <jim@nirmata.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related issue
Implements
validate.foreach
: #1745Milestone of this PR
1.5
What type of PR is this
Proposed Changes
Implements foreach for validate rules
Checklist
Pending Tasks (before merge)
element
to context instead of replacingrequest.object
RuleStatusSkip
when an conditional or global anchors do not match resourceforeach
and fields likelist
.Tasks to be complete after merge to main
validate.foreach
: [Docs] docs for validate & mutate foreach rules website#313