Skip to content
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

Warn if CLI test encounters policy with variables not passed #2120

Closed
chipzoller opened this issue Jul 10, 2021 · 1 comment · Fixed by #2342
Closed

Warn if CLI test encounters policy with variables not passed #2120

chipzoller opened this issue Jul 10, 2021 · 1 comment · Fixed by #2342
Assignees
Labels
enhancement New feature or request type:cli cli releated issue

Comments

@chipzoller
Copy link
Contributor

Is your feature request related to a problem? Please describe.
Very often users are attempting to use the Kyverno CLI to test policies which contain variables but none have been passed in either with --set or in a file. While this is documented, it could be surfaced up in the CLI.

Describe the solution you'd like
Print a warning in the CLI output if a policy is being tested which contains variables that have not been passed in.

Describe alternatives you've considered
Leave everything as is and defer users to the online documentation.

@chipzoller chipzoller added enhancement New feature or request type:cli cli releated issue labels Jul 10, 2021
@chipzoller
Copy link
Contributor Author

chipzoller commented Jul 10, 2021

An error is printed if the command includes the -f flag but the values file has a mismatch of the resource name specified in the deploy.yaml file, for example:

$ k kyverno apply cpol.yaml -r deploy.yaml -f values.yaml 

applying 1 policy to 1 resource... 
Error: policy any-all-preconditions have variables. pass the values for the variables using set/values_file flag

but not if it just passes the policy and a resource:

$ k kyverno apply cpol.yaml -r deploy.yaml

applying 1 policy to 1 resource... 

pass: 0, fail: 0, warn: 0, error: 0, skip: 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request type:cli cli releated issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants