Skip to content

Add support for template secrets #143

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 20, 2023

Conversation

reddec
Copy link
Contributor

@reddec reddec commented Dec 13, 2023

Add support for template secrets.

Users can specify the structure and content of secrets based on their unique requirements using standard
Go templates. This flexibility allows for a more tailored approach to
meeting the specific needs of different applications.

Available context:

Variable Meaning
.Host Database host
.Role Generated user/role name
.Database Referenced database name
.Password Generated role password

Example

apiVersion: db.movetokube.com/v1alpha1
kind: PostgresUser
metadata:
  name: my-db-user
spec:
  role: username
  database: my-db
  secretName: my-secret
  privileges: OWNER
  template:
    PQ_URL: "host={{.Host}} user={{.Role}} password={{.Password}} dbname={{.Database}}"

Change is backward compatible: no need to update existing CRDs in cluster.

@reddec
Copy link
Contributor Author

reddec commented Dec 13, 2023

@hitman99 sorry for bothering you, but could you please review one more PR?

README.md Outdated
@@ -173,6 +174,8 @@ spec:
privileges: OWNER # Can be OWNER/READ/WRITE
annotations: # Annotations to be propagated to the secrets metadata section (optional)
foo: "bar"
template: # Output secrets can be customized using standard Go templates
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that template is a bit misleading, would it be possible to change it to secretTemplate or something else that indicates that this fiel is used to template data in the secret

Copy link
Member

@hitman99 hitman99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's a bit misleading to name that field template. From the name itself it's not clear that it is allowing to template the data in the secret

@reddec
Copy link
Contributor Author

reddec commented Dec 19, 2023

@hitman99 updated

@reddec reddec requested a review from hitman99 December 20, 2023 03:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants