Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert string to YAML map

In values.yaml I have another yaml config encoded to base64. In a template I decode it with

{{ $config := b64dec .Values.config }}

and I need to access it like a map, so what is needed is a kind of analogue of file AsConfig but for string.

like image 996
Nikolay Avatar asked Aug 31 '25 17:08

Nikolay


1 Answers

You can use Helm's fromYaml function (haven't found any documentation besides this commit)

config.yaml which is encoded with cat config.yaml | base64

xxx: yyy
zzz: qqq

values.yaml

config: eHh4OiB5eXkKenp6OiBxcXEK

secret.yaml

{{ $config :=  (b64dec .Values.config) | fromYaml  }}
apiVersion: v1
kind: Secret
metadata:
  name: secret
type: Opaque
data:
  test: {{  $config.xxx }}

helm template

/mnt/c/home/chart> helm template .
---
# Source: chart/templates/secret.yaml
apiVersion: v1
kind: Secret
metadata:
  name: secret
type: Opaque
data:
  test: yyy
like image 144
edbighead Avatar answered Sep 02 '25 23:09

edbighead