From 4f74e03aad663c7d72edaa36d8e874f1ebe1aa2d Mon Sep 17 00:00:00 2001 From: Alan Clucas Date: Thu, 9 Mar 2023 15:26:04 +0000 Subject: [PATCH] Indent values.yaml using 2 instead of 4 spaces (#9656) * Generate values.yaml with indentation of 2 Signed-off-by: Alan Clucas * Fix review comments --------- Signed-off-by: Alan Clucas --- magefiles/helm.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/magefiles/helm.go b/magefiles/helm.go index 93c440584..d56cbed78 100644 --- a/magefiles/helm.go +++ b/magefiles/helm.go @@ -19,6 +19,7 @@ limitations under the License. package main import ( + "bytes" "fmt" "os" "strings" @@ -146,9 +147,12 @@ func updateChartValue(key, value string) { } //// write to file - newValueFile, err := yaml.Marshal(&n) + var b bytes.Buffer + yamlEncoder := yaml.NewEncoder(&b) + yamlEncoder.SetIndent(2) + err = yamlEncoder.Encode(&n) CheckIfError(err, "HELM Could not Marshal new Values file") - err = os.WriteFile(HelmChartValues, newValueFile, 0644) + err = os.WriteFile(HelmChartValues, b.Bytes(), 0644) CheckIfError(err, "HELM Could not write new Values file to %s", HelmChartValues) Info("HELM Ingress Nginx Helm Chart update %s %s", key, value)