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

Policyreport cli #1235

Merged
merged 136 commits into from Nov 18, 2020
Merged

Policyreport cli #1235

merged 136 commits into from Nov 18, 2020

Conversation

NoSkillGirl
Copy link
Contributor

@NoSkillGirl NoSkillGirl commented Nov 10, 2020

Related issue

closes #1065

What type of PR is this?

/kind feature

Proposed changes

This PR supports policy report when the policies manifest is applied on resources passed as file/folder or available in cluster.

Checklist

@NoSkillGirl NoSkillGirl added the wip work in progress label Nov 10, 2020
Copy link
Member

@realshuting realshuting left a comment

Choose a reason for hiding this comment

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

Adding other comments:

  • Here

    if common.PolicyHasVariables(*policy) && variablesString == "" && valuesFile == "" {
    rc.skip += len(resources)
    fmt.Printf("\nskipping policy %s as it has variables. pass the values for the variables using set/values_file flag", policy.Name)
    continue
    }
    if common.PolicyHasVariables(*policy) && variablesString == "" && valuesFile == "" {
    return sanitizedError.NewWithError(fmt.Sprintf("policy %s have variables. pass the values for the variables using set/values_file flag", policy.Name), err)
    }
    it has 2 same checks but different results?

  • Do we still mutate policy before applying it? I'm applying disallow_latest_tag to a deployment, but I don't see the policy report

kyverno apply samples/best_practices/disallow_latest_tag.yaml  --policy-report --cluster -r nginx-2
I1110 18:17:32.585376   25815 client.go:258] dclient/Poll "msg"="starting registered resources sync"  "period"=300000000000
----------------------------------------------------------------------
POLICY REPORT: not generated as no validation failure

pkg/kyverno/common/fetch.go Outdated Show resolved Hide resolved
pkg/kyverno/common/fetch.go Show resolved Hide resolved
pkg/kyverno/common/fetch.go Outdated Show resolved Hide resolved
pkg/utils/loadpolicy.go Outdated Show resolved Hide resolved
pkg/kyverno/apply/command.go Show resolved Hide resolved
@NoSkillGirl NoSkillGirl removed the wip work in progress label Nov 13, 2020
@realshuting
Copy link
Member

@NoSkillGirl Is this doc update to date?

The first three worked for me while case 4 and 5 gave me the following error:

$ kyverno apply samples/best_practices --cluster --policy-report -n default -r nginx
Error: valid resource(s) not provided
Cause: failed to load resources
Cause: the server could not find the requested resource
$ kyverno apply samples/best_practices --cluster --policy-report -n default
Error: valid resource(s) not provided
Cause: failed to load resources
Cause: the server could not find the requested resource

@NoSkillGirl NoSkillGirl merged commit c791c20 into kyverno:main Nov 18, 2020
@NoSkillGirl NoSkillGirl added this to the Kyverno Release 1.3.0 milestone Dec 22, 2020
@realshuting realshuting removed this from the Kyverno Release 1.3.0 milestone Jan 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Generate policy report from Kyverno CLI
4 participants