forked from argoproj/argo-workflows
/
root.go
48 lines (40 loc) · 1.24 KB
/
root.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package commands
import (
"os"
"github.com/argoproj/argo/util/cmd"
"github.com/spf13/cobra"
"k8s.io/client-go/tools/clientcmd"
)
const (
// CLIName is the name of the CLI
CLIName = "argo"
)
var (
// Global CLI flags
globalArgs globalFlags
)
func init() {
RootCmd.AddCommand(cmd.NewVersionCmd(CLIName))
addKubectlFlagsToCmd(RootCmd)
}
func addKubectlFlagsToCmd(cmd *cobra.Command) {
// The "usual" clientcmd/kubectl flags
loadingRules := clientcmd.NewDefaultClientConfigLoadingRules()
loadingRules.DefaultClientConfig = &clientcmd.DefaultClientConfig
overrides := clientcmd.ConfigOverrides{}
kflags := clientcmd.RecommendedConfigOverrideFlags("")
cmd.PersistentFlags().StringVar(&loadingRules.ExplicitPath, "kubeconfig", "", "Path to a kube config. Only required if out-of-cluster")
clientcmd.BindOverrideFlags(&overrides, cmd.PersistentFlags(), kflags)
clientConfig = clientcmd.NewInteractiveDeferredLoadingClientConfig(loadingRules, &overrides, os.Stdin)
}
type globalFlags struct {
noColor bool // --no-color
}
// RootCmd is the argo root level command
var RootCmd = &cobra.Command{
Use: CLIName,
Short: "argo is the command line interface to Argo",
Run: func(cmd *cobra.Command, args []string) {
cmd.HelpFunc()(cmd, args)
},
}