Helm 迭代嵌套列表并在 yaml 中添加带有解码值的输出

Helm iterate over nested list and added output in yaml with decoded value

我在 values.yaml 中有一堆密钥,如下所示。我需要将 secretKey 的每个值添加为 template.data 中的键和解码值,如下所示。

我怎样才能做到这一点?

{{- range $externalSecretName, $externalSecret := .Values.externalSecrets }}
apiVersion: external-secrets.io/v1beta1
kind: ExternalSecret
metadata:
  name: {{ $externalSecretName }}
spec:
  refreshInterval: 1m
  secretStoreRef:
    name: secret
    kind: SecretStore
  target:
    name: {{ $externalSecretName }}
    creationPolicy: Owner
    template:
      data:
        ## Needs to insert/add each secretKey value here like below
        {
          keyname1: "{{ .keyname1 | b64dec }}".  
          keyname2: "{{ .keyname2 | b64dec }}".  
        }

  data:
  {{- toYaml $externalSecret.data | nindent 4 }}
---
{{- end }}


values.yaml:
===========

extraEnvSecret:
  fromSecret:
    name: master-tf-address-handling
    data:
      PREFIX_KEYNAME1: keyname1
      PREFIX_KEYNAME2: keyname2

externalSecrets:
  demo-app:
    data:
      - secretKey: keyname1
        remoteRef:
          key: value1
      - secretKey: keyname2
        remoteRef:
          key: value1
{{- range $externalSecretName, $externalSecret := .Values.externalSecrets }}
apiVersion: external-secrets.io/v1beta1
kind: ExternalSecret
metadata:
  name: {{ $externalSecretName }}
spec:
  refreshInterval: 1m
  secretStoreRef:
    name: secret
    kind: SecretStore
  target:
    name: {{ $externalSecretName }}
    creationPolicy: Owner
    template:
      data:
        {
          {{- range $externalSecret.data }}
             {{ .secretKey }}: "{{ .remoteRef.key | b64enc }}",
          {{- end }}
        }
  data:
    {{- toYaml $externalSecret.data | nindent 4 }}
{{- end }}