kptdev/kpt

[Question] How to create dynamic content based on a variable

WTPascoe opened this issue · 0 comments

What is the right approach or tooling to create dynamic content based on a variable?

In my example, in a dev environment, we want to use a region-specific KMS key for something, but in prod, we need this to be a global key. This isn't as simple as changing part of the key path. The key information in the non-prod (regional config) falls under spec.replication.userManaged.replicas[]

In prod, this configuration is under spec.replication.auto

Regional example

spec:
  replication:
    userManaged:
      replicas:
      - location: europe-west2
        customerManagedEncryption:
          kmsKeyRef:
            external: projects/GCP_PROJECT_ID/locations/europe-west-2/keyRings/env-secretmanager-kmskeyring/cryptoKeys/env-secretmanager-kmskey # kpt-set: projects/${project-id}/locations/europe-west2/keyRings/${env}-secretmanager-kmskeyring/cryptoKeys/${secret-env}-secretmanager-kmskey

Global example

spec:
  replication:
    automatic: true
    auto:
      customerManagedEncryption:
        kmsKeyRef:
          external: projects/GCP_PROJECT_ID/locations/global/keyRings/env-secretmanager-kmskeyring/cryptoKeys/env-secretmanager-kmskey # kpt-set: projects/${project-id}/locations/global/keyRings/${env}-secretmanager-kmskeyring/cryptoKeys/${secret-env}-secretmanager-kmskey