guerzon / vaultwarden

Helm chart for Vaultwarden, the (unofficial) Bitwarden-compatible server written in Rust, formerly known as bitwarden_rs
MIT License
142 stars 64 forks source link

podSpec: use the $ operator while generating secretKeyRefs #94

Closed craigcabrey closed 2 months ago

craigcabrey commented 3 months ago

Inside of range, . refers to the current item during iteration, whereas $ refers to the global scope.

test.yaml:

image:
  extraSecrets:
    - key: SSO_CLIENT_ID
      value: test-value

before:

$ helm template release ./charts/vaultwarden -f test.yaml 
Error: template: vaultwarden/templates/statefulset.yaml:43:10: executing "vaultwarden/templates/statefulset.yaml" at <include "vaultwarden.podSpec" .>: error calling include: template: vaultwarden/templates/_podSpec.tpl:43:21: executing "vaultwarden.podSpec" at <include "vaultwarden.fullname" .>: error calling include: template: vaultwarden/templates/_helpers.tpl:15:14: executing "vaultwarden.fullname" at <.Values.fullnameOverride>: nil pointer evaluating interface {}.fullnameOverride

Use --debug flag to render out invalid YAML

after:

$ helm template release ./charts/vaultwarden -f test.yaml 
---
# Source: vaultwarden/templates/rbac.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
  name: vaultwarden-svc
  namespace: default
  labels:
    app.kubernetes.io/component: vaultwarden
[snip]
          env:
            - name: SSO_CLIENT_ID
              valueFrom:
                secretKeyRef:
                  name: release-vaultwarden
                  key: SSO_CLIENT_ID
[snip]
guerzon commented 2 months ago

Thanks for the PR @craigcabrey, but I merged this via https://github.com/guerzon/vaultwarden/pull/97 since the chart version is updated there.