mirror of
https://github.com/replicatedhq/troubleshoot.git
synced 2026-04-15 07:16:34 +00:00
41 lines
754 B
Go
41 lines
754 B
Go
package cli
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"strings"
|
|
|
|
"github.com/spf13/cobra"
|
|
"github.com/spf13/viper"
|
|
)
|
|
|
|
func RootCmd() *cobra.Command {
|
|
cmd := &cobra.Command{
|
|
Use: "preflight",
|
|
Short: "Run and retrieve preflight checks in a cluster",
|
|
Long: `A preflight check is a set of validations that can and should be run to ensure
|
|
that a cluster meets the requirements to run an application.`,
|
|
SilenceUsage: true,
|
|
}
|
|
|
|
cobra.OnInitialize(initConfig)
|
|
|
|
cmd.AddCommand(Run())
|
|
cmd.AddCommand(Server())
|
|
|
|
viper.SetEnvKeyReplacer(strings.NewReplacer("-", "_"))
|
|
return cmd
|
|
}
|
|
|
|
func InitAndExecute() {
|
|
if err := RootCmd().Execute(); err != nil {
|
|
fmt.Println(err)
|
|
os.Exit(1)
|
|
}
|
|
}
|
|
|
|
func initConfig() {
|
|
viper.SetEnvPrefix("PREFLIGHT")
|
|
viper.AutomaticEnv()
|
|
}
|