Skip to content

fix(cli): color issue for --remove-color flag

Explanation

The string comparison was generating colored output even after adding the --remove-color flag. This actually problem of an individual package that was generating the color with/without --remove-color flag. After passing it through set of function this itself is sorted! (Check the changes)

Related issue

closes #14185

Milestone of this PR

Documentation (required for features)

My PR contains new or altered behavior to Kyverno.

What type of PR is this

This PR fixes bug for CLI.

Proposed Changes

Proof Manifests

kyverno-test.yaml

kind: Test
metadata:
  name: resource-diff-test
policies:
  - policy.yaml
resources:
  - resource.yaml
results:
  - policy: add-label
    rule: add-label
    kind: Pod
    resources:
      - sample-pod
    result: pass
    patchedResources: expected-patched-pod.yaml 

expected-patched-pod.yaml

apiVersion: v1
kind: Pod
metadata:
  name: sample-pod
  labels:
    app: web
    env: staging
spec:
  containers:
    - name: nginx
      image: nginx

policy.yaml

kind: ClusterPolicy
metadata:
  name: add-label
spec:
  background: false
  validationFailureAction: audit
  rules:
    - name: add-label
      match:
        any:
          - resources:
              kinds:
                - Pod
      mutate:
        patchStrategicMerge:
          metadata:
            labels:
              env: prod

resource.yaml

apiVersion: v1
kind: Pod
metadata:
  name: sample-pod
  labels:
    app: web
spec:
  containers:
    - name: nginx
      image: nginx

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.

Further Comments

Merge request reports

Loading