INNER CODE UNIT · Go
TrustedMarshalYAML
helm-unittest/helm-unittest · internal/common/utilities.go:36
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)
}
}()
if err := yamlEncoder.Encode(dEscaped); err != nil {
panic(err)
}
return byteBuffer.String()
}