Skip to content

Conversation

MariamFahmy98
Copy link
Contributor

@MariamFahmy98 MariamFahmy98 commented Nov 24, 2023

Explanation

If --namespace isn't set in kyverno create exception, the namespace field will have an empty value. This PR uses the default namespace in case it isn't set.

Before the fix:

./cmd/cli/kubectl-kyverno/kubectl-kyverno create exception my-exception --policy-rules "policy,rule-1,rule-2" --all "kind=Pod,kind=Deployment,name=test-*"
apiVersion: kyverno.io/v2beta1
kind: PolicyException
metadata:
  name: my-exception
  namespace: 
spec:
  background: true
  match:
    all:
    - kinds:
        - Pod
        - Deployment
      names:
        - test-*
  exceptions:
    - policyName: policy
      ruleNames:
        - rule-1
        - rule-2

Related issue

N/A

Milestone of this PR

/milestone 1.11.1

What type of PR is this

/kind bug

Proposed Changes

Proof Manifests

./cmd/cli/kubectl-kyverno/kubectl-kyverno create exception my-exception --policy-rules "policy,rule-1,rule-2" --all "kind=Pod,kind=Deployment,name=test-*"
apiVersion: kyverno.io/v2beta1
kind: PolicyException
metadata:
  name: my-exception
  namespace: default
spec:
  background: true
  match:
    all:
    - kinds:
        - Pod
        - Deployment
      names:
        - test-*
  exceptions:
    - policyName: policy
      ruleNames:
        - rule-1
        - rule-2

Checklist

  • I have read the contributing guidelines.
  • I have read the PR documentation guide and followed the process including adding proof manifests to this PR.
  • This is a bug fix and I have added unit tests that prove my fix is effective.
  • This is a feature and I have added CLI tests that are applicable.
  • My PR needs to be cherry picked to a specific release branch which is .
  • My PR contains new or altered behavior to Kyverno and
    • CLI support should be added and my PR doesn't contain that functionality.
    • 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 documentation update and the link is:

Further Comments

…no create exception

Signed-off-by: Mariam Fahmy <mariam.fahmy@nirmata.com>
Copy link

codecov bot commented Nov 24, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (d6933ff) 33.60% compared to head (391c594) 33.60%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #9014   +/-   ##
=======================================
  Coverage   33.60%   33.60%           
=======================================
  Files         315      315           
  Lines       24953    24953           
=======================================
  Hits         8386     8386           
  Misses      15769    15769           
  Partials      798      798           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@MariamFahmy98 MariamFahmy98 enabled auto-merge (squash) November 24, 2023 10:58
@MariamFahmy98 MariamFahmy98 merged commit 86dff69 into kyverno:main Nov 24, 2023
@MariamFahmy98 MariamFahmy98 deleted the cli-create-exception branch November 24, 2023 12:23
@MariamFahmy98
Copy link
Contributor Author

/cherry-pick release-1.11

@realshuting
Copy link
Member

@MariamFahmy98 - the cherry-pick failed, can you do that manually?

@realshuting
Copy link
Member

/cherry-pick release-1.11

@realshuting realshuting added the cherry-pick-completed The PR was cherry-picked (or merged) to required release branches label Nov 27, 2023
vishal-chdhry pushed a commit to vishal-chdhry/kyverno that referenced this pull request Jan 5, 2024
…no create exception (kyverno#9014)

Signed-off-by: Mariam Fahmy <mariam.fahmy@nirmata.com>
vishal-chdhry pushed a commit to vishal-chdhry/kyverno that referenced this pull request Jan 5, 2024
…no create exception (kyverno#9014)

Signed-off-by: Mariam Fahmy <mariam.fahmy@nirmata.com>
vishal-chdhry pushed a commit to vishal-chdhry/kyverno that referenced this pull request Jan 6, 2024
…no create exception (kyverno#9014)

Signed-off-by: Mariam Fahmy <mariam.fahmy@nirmata.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherry-pick-completed The PR was cherry-picked (or merged) to required release branches cherry-pick-required
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants