Feature/support env hcl and interpolations (#1423)

* support HCL language for env variables

Signed-off-by: xtphate <65117176+XT-Phate@users.noreply.github.com>
This commit is contained in:
xtphate
2024-04-22 08:02:14 +08:00
committed by GitHub
parent b703b5e061
commit a15a1b0731
29 changed files with 1897 additions and 118 deletions
@@ -0,0 +1,4 @@
helmfileArgs:
- template
- --concurrency=1
- -q
@@ -0,0 +1,38 @@
environments:
default:
values:
- values1.hcl
- values1.yaml
- values2.hcl
---
helmDefaults:
kubeContext: minikube
releases:
- name: hcl-demo
chart: ../../charts/raw-0.1.0
values:
- templates:
- |
apiVersion: v1
kind: ConfigMap
metadata:
name: configmap
data:
a: {{ .Values.a }}
b: {{ .Values.b }}
c: {{ .Values.c }}
crossfile: {{ .Values.crossfile }}
expressionInText: "{{ .Values.expressionInText }}"
fromMap: {{ .Values.fromMap }}
insideFor: {{ .Values.insideFor }}
list: "{{ .Values.list }}"
{{- .Values.locals | toYaml | nindent 10 -}}
multiBlock: {{ .Values.multiBlock }}
simpleCompute: "{{ .Values.simpleCompute }}"
yamlOverride: {{ .Values.yamlOverride }}
@@ -0,0 +1,20 @@
---
# Source: raw/templates/resources.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: configmap
data:
a: a
b: b
c: ab
crossfile: values2.hcl
expressionInText: "yes"
fromMap: ab
insideFor: b
list: "[b]"
filename: values1.hcl
multiBlock: block
simpleCompute: "4"
yamlOverride: yaml_overrode
@@ -0,0 +1,53 @@
locals {
filename = "values1.hcl"
}
values {
a = "a"
b = "b"
c = "${hv.a}${hv.b}"
list = [
hv.b
]
locals = local
// Maps and some functions
nestedmap = {
submap = {
subsubmap = {
hello = hv.a
}
}
}
nestedmap2 = {
submap = {
subsubmap = {
hello = hv.c
}
}
}
merged = merge(hv.nestedmap, hv.nestedmap2)
fromMap = "${hv.merged.submap.subsubmap.hello}"
// precedence demo
yamlOverride = "yaml_overrode"
// Simple Expressions
ternary = true ? true : false
expressionInText = "%{if hv.ternary }yes%{else}no%{endif}"
insideFor = "%{for i in hv.list }${i}%{endfor}"
simpleCompute = 2 + 2
multiBlock = hv.block
crossfile = hv.crossfile_var
}
values {
block = "block"
}
@@ -0,0 +1 @@
yamlOverride: "will_be_overriden"
@@ -0,0 +1,7 @@
locals {
filename = "values2.hcl"
}
values {
crossfile_var = local.filename
}