mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-10 12:32:03 +00:00
Merge pull request #118066 from BenTheElder/yamlfmt-cleanup
yamlfmt cleanup
This commit is contained in:
commit
9d613da22b
@ -1,4 +1,10 @@
|
||||
# See the OWNERS docs at https://go.k8s.io/owners
|
||||
|
||||
reviewers:
|
||||
- bentheelder
|
||||
- dims
|
||||
approvers:
|
||||
- dims
|
||||
labels:
|
||||
- sig/testing
|
||||
- sig/contributor-experience
|
||||
|
@ -28,29 +28,26 @@ import (
|
||||
func main() {
|
||||
indent := flag.Int("indent", 2, "default indent")
|
||||
flag.Parse()
|
||||
|
||||
if flag.NArg() > 0 {
|
||||
for _, path := range flag.Args() {
|
||||
sourceYaml, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "%s: %v\n", path, err)
|
||||
continue
|
||||
}
|
||||
rootNode, err := fetchYaml(sourceYaml)
|
||||
if err != nil {
|
||||
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 {
|
||||
fmt.Fprintf(os.Stderr, "%s: %v\n", path, err)
|
||||
continue
|
||||
}
|
||||
err = streamYaml(writer, indent, rootNode)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "%s: %v\n", path, err)
|
||||
continue
|
||||
}
|
||||
for _, path := range flag.Args() {
|
||||
sourceYaml, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "%s: %v\n", path, err)
|
||||
continue
|
||||
}
|
||||
rootNode, err := fetchYaml(sourceYaml)
|
||||
if err != nil {
|
||||
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 {
|
||||
fmt.Fprintf(os.Stderr, "%s: %v\n", path, err)
|
||||
continue
|
||||
}
|
||||
err = streamYaml(writer, indent, rootNode)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "%s: %v\n", path, err)
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user