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

policy-controller: fix empty values #835

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

walnuts1018
Copy link

@walnuts1018 walnuts1018 commented Sep 15, 2024

Description of the change

This PR fixes the issue where only the key is output when the value is not provided for some fields such as .Values.annotations and .Values.webhook.podDisruptionBudget.maxUnavailable.

Existing or Associated Issue(s)

Additional Information

The state in which only the key is output, such as annotations: , is not syntactically correct in yaml, so lint tools such as kubeconform output an error.
In this PR, the position of the conditional branch has been slightly changed so that if value is not specified, key is also not output.

$ helm install policy-controller sigstore/policy-controller -n policy-controller --dry-run > old.yaml
$ helm install policy-controller ./charts/policy-controller -n policy-controller --dry-run > new.yaml
$ dyff between .\old.yaml .\new.yaml

old.yaml:

...
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
  name: policy-controller-webhook
  labels:
    helm.sh/chart: policy-controller-0.7.0
    app.kubernetes.io/name: policy-controller
    app.kubernetes.io/instance: policy-controller
    app.kubernetes.io/version: "0.8.2"
    app.kubernetes.io/managed-by: Helm
    control-plane: policy-controller-webhook
  annotations:
spec:
  minAvailable: 1
  maxUnavailable: 
  selector:
    matchLabels:
      app.kubernetes.io/name: policy-controller
      app.kubernetes.io/instance: policy-controller
      control-plane: policy-controller-webhook
...

new.yaml:

...
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
  name: policy-controller-webhook
  labels:
    helm.sh/chart: policy-controller-0.7.0
    app.kubernetes.io/name: policy-controller
    app.kubernetes.io/instance: policy-controller
    app.kubernetes.io/version: "0.8.2"
    app.kubernetes.io/managed-by: Helm
    control-plane: policy-controller-webhook
spec:
  minAvailable: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: policy-controller
      app.kubernetes.io/instance: policy-controller
      control-plane: policy-controller-webhook
...

Output:

metadata  (document #6)
  - one map entry removed:
    annotations:

spec  (document #6)
  - one map entry removed:
    maxUnavailable:

metadata  (document #8)
  - one map entry removed:
    annotations:

metadata  (document #19)
  - one map entry removed:
    annotations:

metadata  (document #20)
  - one map entry removed:
    annotations:

spec.template.spec.containers.policy-controller-webhook  (document #21)
  - one map entry removed:
    args:

Checklist

  • Chart version bumped in Chart.yaml according to semver. Where applicable, update and bump the versions in any associated umbrella chart
  • Variables are documented in the values.yaml and added to the README.md. The helm-docs utility can be used to generate the necessary content. Use helm-docs --dry-run to preview the content.
  • JSON Schema generated.
  • List tests pass for Chart using the Chart Testing tool and the ct lint command.

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.

2 participants