From 0637973e4014faaced601d2fda80442e11048972 Mon Sep 17 00:00:00 2001 From: Chris Mellard Date: Sun, 13 Dec 2020 14:08:03 +1300 Subject: [PATCH] fix: allow helmfiles to be corrected marshalled to YAML so they can be manipulated by other programs (#1604) --- pkg/state/state.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/pkg/state/state.go b/pkg/state/state.go index fc7d0f94..76e01466 100644 --- a/pkg/state/state.go +++ b/pkg/state/state.go @@ -2675,6 +2675,23 @@ func escape(value string) string { return strings.Replace(intermediate, ",", "\\,", -1) } +//MarshalYAML will ensure we correctly marshal SubHelmfileSpec structure correctly so it can be unmarshalled at some +//future time +func (p SubHelmfileSpec) MarshalYAML() (interface{}, error) { + type SubHelmfileSpecTmp struct { + Path string `yaml:"path,omitempty"` + Selectors []string `yaml:"selectors,omitempty"` + SelectorsInherited bool `yaml:"selectorsInherited,omitempty"` + OverrideValues []interface{} `yaml:"values,omitempty"` + } + return &SubHelmfileSpecTmp{ + Path: p.Path, + Selectors: p.Selectors, + SelectorsInherited: p.SelectorsInherited, + OverrideValues: p.Environment.OverrideValues, + }, nil +} + //UnmarshalYAML will unmarshal the helmfile yaml section and fill the SubHelmfileSpec structure //this is required to keep allowing string scalar for defining helmfile func (hf *SubHelmfileSpec) UnmarshalYAML(unmarshal func(interface{}) error) error {