uswitch / vault-creds

Sidecar container for requesting dynamic Vault database secrets
Apache License 2.0
84 stars 14 forks source link

Add environment variables to template rendering #26

Closed DaspawnW closed 5 years ago

DaspawnW commented 5 years ago

The credentials endpoint in Vault don't return for example the name of the database or the host information about the database. To have one file with all db related connection information it would be good to also include host information or database name information. Therefore the following change allows to render environment variables provided to the Pod, e.g.:

env:
  - name: HOST
    value: localhost:5432
  - name: DBNAME
    value: postgresql
spring.datasource.url: jdbc:postgresql://{{ .HOST }}/{{ .DBNAME }}
spring.datasource.username: {{ .Username }}
spring.datasource.password: {{ .Password }}

Output:

spring.datasource.url: jdbc:postgresql://localhost:5432/postgresql
spring.datasource.username: User
spring.datasource.password: VERYSECUREPASSWORD
Joseph-Irving commented 5 years ago

Hey thanks for this PR! looks like a good useful change, I left one nitpick

DaspawnW commented 5 years ago

I'd be very happy if you'd take over the merge. Thank you for the note :-)