Skip to content

rewrite template.data keys #464

@vkruoso

Description

@vkruoso

Describe the solution you'd like
When templating from multiple sources (data and dataFrom config), be able to render in the template all values from the dataFrom secret with the values from the data secret.

What is the added value?
This allow for a less verbose ExternalSecret object and more flexible, as adding / removing keys from the dataFrom secret source will be reflected in the secret without any object change

Give us examples of the outcome
Now we need to do the config below. Explicit list the keys from the dataFrom field, ENV1FROMDATAFROM and ENV2FROMDATAFROM, in this example.

apiVersion: external-secrets.io/v1alpha1
kind: ExternalSecret
metadata:
  name: my-server-env
spec:
  secretStoreRef:
    name: my-cluster-secret-store
    kind: ClusterSecretStore
  dataFrom:
  - key: /my-server
  data:
  - secretKey: S3_BUCKET
    remoteRef:
      key: /my-server/S3_BUCKET
  - secretKey: AWS_ACCESS_KEY_ID
    remoteRef:
      key: /my-server/AWS_ACCESS_KEY_ID
  - secretKey: AWS_SECRET_ACCESS_KEY
    remoteRef:
      key: /my-server/AWS_SECRET_ACCESS_KEY
  target:
    name: my-server-env
    creationPolicy: Owner
    template:
      data:
        ENV1FROMDATAFROM: |
          {{ .ENV1FROMDATAFROM | toString }}
        ENV2FROMDATAFROM: |
          {{ .ENV1FROMDATAFROM | toString }}
        S3_BUCKET: |
          {{ .S3_BUCKET | toString }}
        AWS_ACCESS_KEY_ID: |
          {{ .AWS_ACCESS_KEY_ID | toString }}
        AWS_SECRET_ACCESS_KEY: |
          {{ .AWS_SECRET_ACCESS_KEY | toString }}

Ideally if we could have the possibility to do templating directly in the template.data field:

    template:
      data:
        {{- range $key, $val := . }}
        {{ $key }}: {{ $val | toString }}
        {{- end}}

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/templatingIssues / Pull Requests related to templating engineskind/featureCategorizes issue or PR as related to a new feature.

    Type

    No type

    Projects

    Status

    Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions