fix(clustertool): new round of indent fixes

This commit is contained in:
Kjeld Schouten
2025-04-09 15:15:50 +02:00
parent d5e6babdf8
commit b3c027f0c8
794 changed files with 24607 additions and 25078 deletions
+23 -2
View File
@@ -2,9 +2,30 @@ package helper
import (
"bytes"
"strings"
"gopkg.in/yaml.v3"
)
func MarshalYaml(buf *bytes.Buffer, v interface{}) error {
enc := YamlNewEncoder(buf)
return enc.Encode(v)
var tmpBuf bytes.Buffer
enc := yaml.NewEncoder(&tmpBuf)
enc.SetIndent(2)
defer enc.Close()
if err := enc.Encode(v); err != nil {
return err
}
// Remove indent from top-level keys (lines that are not indented)
lines := strings.Split(tmpBuf.String(), "\n")
for _, line := range lines {
if strings.HasPrefix(line, " ") {
buf.WriteString(line + "\n")
} else {
buf.WriteString(strings.TrimLeft(line, " ") + "\n")
}
}
return nil
}
+1 -1
View File
@@ -4,7 +4,7 @@ import (
"bytes"
"io"
"sigs.k8s.io/yaml"
"gopkg.in/yaml.v3"
)
// Encoder is a custom encoder for YAML that writes to an io.Writer.