Merge pull request #111135 from thockin/yamlfmt-print-filenames

Make yamlfmt tool print filenames
This commit is contained in:
Kubernetes Prow Robot 2022-07-15 03:46:25 -07:00 committed by GitHub
commit f8e80d32c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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
}
}
}