hydra-maester icon indicating copy to clipboard operation
hydra-maester copied to clipboard

Ability to set template/metadata on generated secrets

Open adamstrawson opened this issue 3 years ago • 0 comments

Preflight checklist

Describe your problem

We have tooling that performs actions when a configmap/secret changes based on annotations.

It would be nice to be able to include metadata (specially annotations) within the secret that hydra-maester creates.

Describe your ideal solution

Within the Custom Resource, i'd like to define a spec template form which to create the secret, in a similar format to below:

apiVersion: hydra.ory.sh/v1alpha1
kind: OAuth2Client
metadata:
  name: my-client
spec:
  grantTypes:
    - client_credentials
  scope: my-scope
  secret:
    name: my-test-secret
    template:
      metadata:
        annotations:
          hello/world: foo
  clientName: foobar

The generated secret would then look like:

apiVersion: v1
kind: Secret
metadata:
  name: my-test-secret
  namespace: test
  annotations:
    hello/world: foo
  ownerReferences:
    - apiVersion: hydra.ory.sh/v1alpha1
      kind: OAuth2Client
      name: my-client
      uid: 1234-1234
data:
  client_id: aGVsbG8tZGlkLXlvdS1yZWFsbHktY2hlY2stdGhpcw==
  client_secret: aS13b3VsZC1saWtlLXNvbWUtcGllLXBsZWFzZQ==
type: Opaque

For backwards compatibility, we could support both secretName and secret.name with the intention of deprecating secretName in a future version.

Workarounds or alternatives

N/A

Version

N/A

Additional Context

Happy to PR if we feel this is a welcome addition.

adamstrawson avatar Jan 05 '23 18:01 adamstrawson