Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to get a value from the secret when a key contains got?

My secret file looks like:

apiVersion: v1
kind: Secret
metadata:
  name: secret
type: Opaque
stringData:
  "user.name":  "user"
  "user.password":  "password"

And I am trying to get a value with the next code:

{{- $secret := lookup "v1" "Secret" .Release.Namespace "secret" -}}
  {{- if $secret -}}
       {{- print $secret.data.user.password}}

The problem is "user.password" key contains a dot and I haven’t found how to fix it.
Thanks for any help!

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You can use the index function to access map values with dots in them like:

{{- print (index $secret.data "user.password")}}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading