Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // RootCmd is the command to run for kubernetes json schema validation. RootCmd = &cobra.Command{ Use: "kubeschema <file> [file...]", Short: "Validate kubernetes json schema for helm chart YAML file", Long: `Validate kubernetes json schema for helm chart YAML file`, Run: func(cmd *cobra.Command, args []string) { if version { printVersion() os.Exit(0) } success, windowsStdinIssue := true, false stat, err := os.Stdin.Stat() if err != nil { if runtime.GOOS != "windows" { logger.Error(red(err)) os.Exit(1) } else { windowsStdinIssue = true } } if (len(args) < 1 || args[0] == "-") && !windowsStdinIssue && ((stat.Mode() & os.ModeCharDevice) == 0) { var buffer bytes.Buffer scanner := bufio.NewScanner(os.Stdin) for scanner.Scan() { buffer.WriteString(scanner.Text() + "\n") } results, err := validator.Validate(buffer.Bytes(), viper.GetString("filename")) if err != nil { logger.Error(red(err)) os.Exit(1) } success = logResults(results, success) } else { if len(args) < 1 { logger.Error(red("Missing filename in argument")) os.Exit(1) } for _, fileName := range args { filePath, _ := filepath.Abs(fileName) fileContents, err := ioutil.ReadFile(filePath) if err != nil { logger.Error(red("Failed to open file ", fileName)) os.Exit(1) } results, err := validator.Validate(fileContents, fileName) if err != nil { logger.Error(red(err)) os.Exit(1) } success = logResults(results, success) } } if !success { os.Exit(1) } }, } )
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.