apiVersion: v1
kind: Secret
metadata:
  {{- include "nats.metadataNamespace" $ | nindent 2 }}
  name: {{ .Values.natsBox.contentsSecret.name }}
  labels:
    {{- include "natsBox.labels" $ | nindent 4 }}
type: Opaque
stringData:
  {{- range $ctxKey, $ctxVal := .Values.natsBox.contexts }}
  {{- range $secretKey, $secretVal := dict "creds" "creds" "nkey" "nk" }}
  {{- $secret := get $ctxVal $secretKey }}
  {{- if and $secret $secret.contents }}
  "{{ $ctxKey }}.{{ $secretVal }}": {{ $secret.contents | quote }}
  {{- end }}
  {{- end }}
  {{- end }}