This is backup docs for this Go Template Playground setup: here
The idea is that we want to use External Secrets Operator to parse a secret that happens to be a Redis database URL. We want to be able to split the URL into its pieces so we can use them in our apps downstream. This will let us maintain one "official" secret payload in our secret pipeline but have multiple variants of it downstream in our apps.
template:
URL: {{ .url }}
Proto: {{ (split "://" .url)._0 }}
Host: {{ (split ":" (split "/" (split "://" .url)._1)._0)._0 }}
Port: {{ (split ":" (split "/" (split "://" .url)._1)._0)._1 }}
DB Index: {{ (split "/" (split "://" .url)._1)._1 }}
Address: {{ (split ":" (split "/" (split "://" .url)._1)._0)._0 }}:{{ (split ":" (split "/" (split "://" .url)._1)._0)._1 }}
input:
{
"url": "redis://10.1.2.3:6378/4"
}
output:
URL: redis://10.1.2.3:6378/4
Proto: redis
Host: 10.1.2.3
Port: 6378
DB Index: 4
Address: 10.1.2.3:6378