Skip to content
Snippets Groups Projects
Commit 3c1a6825d3f1 authored by steeve.chailloux's avatar steeve.chailloux
Browse files

fix HelmChart.Values hydration

parent 6ee63476c95b
No related branches found
No related tags found
No related merge requests found
package main
import (
"orus.io/cloudcrane/beaver/cmd"
"os"
......@@ -4,5 +5,3 @@
"os"
"orus.io/cloudcrane/beaver/cmd"
)
......@@ -7,6 +6,6 @@
)
func main () {
func main() {
if code := cmd.Run(); code != 0 {
os.Exit(code)
}
......
......@@ -136,11 +136,7 @@
for name, chart := range c.Spec.Charts.Helm {
var newVals []string
for _, value := range chart.Values {
rawChartValue, err := yaml.Marshal(value)
if err != nil {
return fmt.Errorf("failed to get chart values as string: %w", err)
}
valueTmpl, err := template.New("chart").Parse(string(rawChartValue))
valueTmpl, err := template.New("chart").Parse(value)
if err != nil {
return fmt.Errorf("failed to parse chart values as template: %q, %w", chart.Values, err)
}
......
......@@ -29,7 +29,12 @@
// TODO: make sure this is the expected values including the leading | ...
assert.Equal(t, []string{
"|\n config:\n datasource:\n password: <path:cnpp.k8s.cloudcrane.io/data/ns1/postgres#password>\n role: 'admin'\n fullnameoverride: pg-exporter-ns1\n"},
`config:
datasource:
password: <path:cnpp.k8s.cloudcrane.io/data/ns1/postgres#password>
role: 'admin'
fullnameoverride: pg-exporter-ns1
`},
c.Spec.Charts.Helm["postgres"].Values,
)
}
......@@ -17,9 +17,9 @@
}
type HelmChart struct {
Type string `mapstructure:"type"`
Name string `mapstructure:"name"`
Values interface{} `mapstructure:"values"`
Type string `mapstructure:"type"`
Name string `mapstructure:"name"`
Values map[string]interface{} `mapstructure:"values"`
}
type YttChart struct {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment