Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var RootCmd = &cobra.Command{ Use: "kubetest <file> [file...]", Short: "Run tests against a Kubernetes YAML file", Long: `Run tests against a Kubernetes YAML file`, Run: func(cmd *cobra.Command, args []string) { initLogging() success := true windowsStdinIssue := false testsDir := viper.GetString("testsDir") stat, err := os.Stdin.Stat() if err != nil { if runtime.GOOS != "windows" { log.Error(err) os.Exit(1) } else { windowsStdinIssue = true } } if !windowsStdinIssue && ((stat.Mode() & os.ModeCharDevice) == 0) { var buffer bytes.Buffer scanner := bufio.NewScanner(os.Stdin) for scanner.Scan() { buffer.WriteString(scanner.Text() + "\n") } runSuccess := kubetest.Runs(buffer.Bytes(), testsDir, "stdin") if success { success = runSuccess } } else { if len(args) < 1 { log.Fatal("You must pass at least one file as an argument") } for _, fileName := range args { filePath, _ := filepath.Abs(fileName) fileContents, err := ioutil.ReadFile(filePath) if err != nil { log.Fatal("Could not open file ", fileName) } runSuccess := kubetest.Runs(fileContents, testsDir, fileName) if success { success = runSuccess } } } if !success { os.Exit(1) } }, }
RootCmd represents the the command to run when kubetest is run
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.