in cmd/celfmt/main.go [165:184]
func celFmtYAML(src string) (string, error) {
var n yaml.Node
err := yaml.Unmarshal([]byte(src), &n)
if err != nil {
return "", err
}
if len(n.Content) != 1 && len(n.Content[0].Content) != 2 {
return "", fmt.Errorf("unexpected shape")
}
var buf strings.Builder
err = celFmt(&buf, n.Content[0].Content[1].Value)
if err != nil {
return "", warn{err}
}
// We should be able to do this properly, but there is no
// non-buggy YAML library that will not double-quote some
// programs.
return "program: |-\n " + strings.ReplaceAll(buf.String(), "\n", "\n ") + "\n", nil
}