INNER CODE UNIT · Go
YamlNewEncoder
helm-unittest/helm-unittest · internal/common/utilities.go:31
func YamlNewEncoder(w io.Writer) *yamlv3.Encoder {
return yamlv3.NewEncoder(w)
}
// TrustedMarshalYAML marshal yaml without error returned, if an error happens it panics
func TrustedMarshalYAML(d any) string {
// https://github.com/helm-unittest/helm-unittest/issues/756
// As a temporary fix remove starting new lines in the whole document.
dEscaped := removeLeadingNewLines(d)
byteBuffer := new(bytes.Buffer)
yamlEncoder := YamlNewEncoder(byteBuffer)
yamlEncoder.SetIndent(YAMLINDENTION)
defer func() {
cerr := yamlEncoder.Close()
if cerr != nil {
panic(cerr)
}
}()