mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-19 09:52:49 +00:00
Make yamlfmt tool print filenames
Otherwise fixing errors YAML is much harder.
This commit is contained in:
parent
f3654386ab
commit
722ebf8dca
@ -18,6 +18,7 @@ package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
|
||||
@ -32,19 +33,23 @@ func main() {
|
||||
for _, path := range flag.Args() {
|
||||
sourceYaml, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
fmt.Fprintf(os.Stderr, "%s: %v\n", path, err)
|
||||
continue
|
||||
}
|
||||
rootNode, err := fetchYaml(sourceYaml)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
fmt.Fprintf(os.Stderr, "%s: %v\n", path, err)
|
||||
continue
|
||||
}
|
||||
writer, err := os.OpenFile(path, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0666)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
fmt.Fprintf(os.Stderr, "%s: %v\n", path, err)
|
||||
continue
|
||||
}
|
||||
err = streamYaml(writer, indent, rootNode)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
fmt.Fprintf(os.Stderr, "%s: %v\n", path, err)
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user