Generate values.yaml with indentation of 2

Signed-off-by: Alan Clucas <alan@clucas.org>
This commit is contained in:
Alan Clucas 2023-02-21 17:06:06 +00:00
parent d21ae2dbf6
commit 939c540298

View file

@ -19,6 +19,7 @@ limitations under the License.
package main
import (
"bytes"
"fmt"
semver "github.com/blang/semver/v4"
"github.com/helm/helm/pkg/chartutil"
@ -26,6 +27,7 @@ import (
"github.com/magefile/mage/sh"
yamlpath "github.com/vmware-labs/yaml-jsonpath/pkg/yamlpath"
"gopkg.in/yaml.v3"
"io/ioutil"
"os"
"strings"
)
@ -145,9 +147,13 @@ func updateChartValue(key, value string) {
}
//// write to file
newValueFile, err := yaml.Marshal(&n)
var b bytes.Buffer
yamlEncoder := yaml.NewEncoder(&b)
yamlEncoder.SetIndent(2)
yamlEncoder.Encode(&n)
err = yamlEncoder.Encode(&n)
CheckIfError(err, "HELM Could not Marshal new Values file")
err = os.WriteFile(HelmChartValues, newValueFile, 0644)
err = ioutil.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)