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

Kustomize error: Mapping key "securityContext" already defined #138

Open
alexhampu opened this issue Jan 19, 2024 · 1 comment
Open

Kustomize error: Mapping key "securityContext" already defined #138

alexhampu opened this issue Jan 19, 2024 · 1 comment

Comments

@alexhampu
Copy link

alexhampu commented Jan 19, 2024

I am trying to build the chart with Kustomize, and because in templates/infrastructure/cronjob.yaml there is a default securityContext: {} defined, and then at the end there is an if else statement with:

          {{ if .Capabilities.APIVersions.Has "project.openshift.io/v1/Project" }}
          securityContext:
            seccompProfile:
              type: RuntimeDefault
            runAsNonRoot: true
          {{ else }}
          securityContext:
            fsGroup: 10001
            supplementalGroups: [10001]
            seccompProfile:
              type: RuntimeDefault
            runAsNonRoot: true
            runAsUser: 10001
            runAsGroup: 10001
          {{ end }}

When kustomize tries to build the Chart it sees that securityContext is already defined. Is there any reason why the initial securityContext: {} is needed? Because there is the if else statement, which will always go to else if the condition is not true.

Specific error from kustomize:

error: map[string]interface {}(nil): yaml: unmarshal errors:
  line 83: mapping key "securityContext" already defined at line 77

If securityContext: {} is removed from the templates/infrastructure/cronjob.yaml it works fine.

https://github.com/OpenUnison/helm-charts/blob/master/orchestra/templates/infrastructure/cronjob.yaml#L107

@jpmaas
Copy link

jpmaas commented Dec 23, 2024

This is fixed in the latest release of the chart. See c0d7e8d

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

No branches or pull requests

2 participants