Skip to content

Commit

Permalink
Merge pull request #111135 from thockin/yamlfmt-print-filenames
Browse files Browse the repository at this point in the history
Make yamlfmt tool print filenames
  • Loading branch information
k8s-ci-robot committed Jul 15, 2022
2 parents a0fe0d6 + 722ebf8 commit f8e80d3
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions cmd/yamlfmt/yamlfmt.go
Expand Up @@ -18,6 +18,7 @@ package main

import (
"flag"
"fmt"
"io"
"os"

Expand All @@ -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
}
}
}
Expand Down

0 comments on commit f8e80d3

Please sign in to comment.