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 yaml upon empty volumeMounts or volumes #855

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

Conversation

thoraage
Copy link

Today it create illegal yaml with undefined volumeMounts and volumes yielding these messages from kubeval: WARN - stdin contains an invalid Pod (vault.helm-vault-server-test) - spec.containers.0.volumeMounts: Invalid type. Expected: array, given: null WARN - stdin contains an invalid Pod (vault.helm-vault-server-test) - spec.volumes: Invalid type. Expected: array, given: null

Instead; insert empty lists.

Today it create illegal yaml with undefined volumeMounts and volumes yielding these messages from kubeval:
WARN - stdin contains an invalid Pod (vault.helm-vault-server-test) - spec.containers.0.volumeMounts: Invalid type. Expected: array, given: null
WARN - stdin contains an invalid Pod (vault.helm-vault-server-test) - spec.volumes: Invalid type. Expected: array, given: null

Instead; insert empty lists.
@hashicorp-cla
Copy link

hashicorp-cla commented Mar 21, 2023

CLA assistant check
All committers have signed the CLA.

@@ -46,10 +46,14 @@ spec:
volumeMounts:
{{- if .Values.server.volumeMounts }}
Copy link

@arve0 arve0 Apr 13, 2023

Choose a reason for hiding this comment

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

Could also move the if statement one line up, to make it include the key, in example:

      {{- if .Values.server.volumeMounts }}
      volumeMounts:
          {{- toYaml .Values.server.volumeMounts | nindent 8}}
      {{- end }}

Copy link
Author

Choose a reason for hiding this comment

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

Changed it now (better late than never)

Copy link
Member

@tvoran tvoran left a comment

Choose a reason for hiding this comment

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

I think @arve0's suggestion makes sense, and it would also be good to add a test to test/unit/server-test.bats to check that the rendering for empty volumes is correct.

@thoraage thoraage requested a review from a team as a code owner November 23, 2023 12:15
Copy link
Member

@tvoran tvoran left a comment

Choose a reason for hiding this comment

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

Thanks! I think the only thing missing here is a test in test/unit/server-test.bats to verify that volumeMounts and volumes are not rendered when server.volumeMounts and server.volumes are not set.

@thoraage thoraage requested a review from a team as a code owner September 14, 2024 07:28
@thoraage
Copy link
Author

Added some tests.... a long time after

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.

4 participants