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

Fix for commented yaml files in Kyverno CLI #1849

Merged

Conversation

NoSkillGirl
Copy link
Contributor

@NoSkillGirl NoSkillGirl commented Apr 29, 2021

Signed-off-by: NoSkillGirl singhpooja240393@gmail.com

Related issue

Closes #1848, #1845

What type of PR is this

/kind bug

Proposed Changes

skipping yaml file when kind is missing.

Proof Manifests

policy.yaml:

# FOO
---
apiVersion: kyverno.io/v1
kind: ClusterPolicy
metadata:
  name: portefaix-M0003
  annotations:
    policies.kyverno.io/title: portefaix-M0003
    policies.kyverno.io/category: Best Practices
    policies.kyverno.io/severity: medium
    policies.kyverno.io/description: >-
      Metadata should have annotations
spec:
  validationFailureAction: audit
  rules:
  - name: check-for-annotations
    match:
      resources:
        kinds:
        - Pod
    validate:
      message: "Annotations is required."
      pattern:
        metadata:
          annotations:
            foo: "?*"

resource.yaml:

# FOO
---
apiVersion: v1
kind: Pod
metadata:
  name: myapp-pod-ok
  annotations:
    foo: bar
spec:
  containers:
  - name: nginx
    image: nginx:1.12

Command:
kyverno apply policy.yaml -r resource.yaml

Result:

applying 1 policy to 1 resource... 

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

Checklist

  • I have read the contributing guidelines.
  • [] I have added tests that prove my fix is effective or that my feature works.
  • [] My PR contains new or altered behavior to Kyverno and
    • [] I have added or changed the documentation myself in an existing PR and the link is:
    • [] I have raised an issue in kyverno/website to track the doc update and the link is:
    • [] I have read the PR documentation guide and followed the process including adding proof manifests to this PR.

Signed-off-by: NoSkillGirl <singhpooja240393@gmail.com>
@NoSkillGirl NoSkillGirl added the wip work in progress label Apr 29, 2021
Signed-off-by: NoSkillGirl <singhpooja240393@gmail.com>
@NoSkillGirl NoSkillGirl removed the wip work in progress label Apr 29, 2021
@realshuting realshuting self-assigned this Apr 29, 2021
@realshuting realshuting merged commit d3e4fed into kyverno:main Apr 29, 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.

[BUG]Kyverno CLI Can not test if policy file is with comment
2 participants