diff --git a/cmd/yaml-lint/main.go b/cmd/yaml-lint/main.go index b641f548066..79d6f65339a 100644 --- a/cmd/yaml-lint/main.go +++ b/cmd/yaml-lint/main.go @@ -1,51 +1,25 @@ -package main +/* +Copyright 2020 The Kubernetes Authors. -import ( - "fmt" - "os" - "strings" +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at - "sigs.k8s.io/yaml" -) + http://www.apache.org/licenses/LICENSE-2.0 -// validateYAML reads and parses the YAML file at the given path. -func validateYAML(filePath string) string { - data, err := os.ReadFile(filePath) - if err != nil { - return fmt.Sprintf("Error reading %s:\n%s", filePath, err.Error()) - } +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ - var content interface{} - if err := yaml.UnmarshalStrict(data, &content); err != nil { - return fmt.Sprintf("Error in %s:\n%w", filePath, err.Error()) - } +package main - return "Valid" -} +import ( + "k8s.io/release/cmd/publish-release/cmd" +) func main() { - if len(os.Args) < 2 { - fmt.Println("No YAML files specified.") - os.Exit(1) - } - - files := os.Args[1:] - invalidFiles := []string{} - - for _, file := range files { - result := validateYAML(file) - if result != "Valid" { - invalidFiles = append(invalidFiles, result) - } - } - - if len(invalidFiles) > 0 { - fmt.Println("YAML Validation Failed:\n") - for _, errorMsg := range invalidFiles { - fmt.Println(errorMsg) - fmt.Println("\n" + strings.Repeat("-", 40) + "\n") - } - } else { - fmt.Println("All YAML files are valid 🎉.") - } + cmd.Execute() }