sprig
sprig copied to clipboard
[FEATURE REQUEST] Add urlencode template function
Hello, I had this requirement while using sprig in Helm.
My use case is simple, on multiple occasions, I have to supply a username/password on a uri with basic authentication, but sometimes the passwords have special characters. I'd like a way to url encode the supplied passwords.
Example:
With this values.yaml
file:
username: postgres
password: $@cr4d
endpoint: psql.ns:5432
database: test
This template:
name: psqlUri
value: "--backend-store-uri=postgresql://{{ .Values.username }}:{{ .Values.password | urlenc }}@{{ .Values.endpoint }}/{{ .Values.database }}
Should render:
name: psqlUri
value: "--backend-store-uri=postgresql://postgres:%24%40cr4d%[email protected]:5432/test
The solution to supply it already encoded is impractical because it might be annoying for some users, and I might need to supply it in its raw form elsewhere on the helm. In this particular example I might also need it to create the postgresql secret with the env var PGPASSWORD
.
Is there any difficulty to include this feature?
In 2017 someone already prepared a PR https://github.com/Masterminds/sprig/pull/62 that could be reused.