-
Notifications
You must be signed in to change notification settings - Fork 1
/
root.go
48 lines (39 loc) · 1.3 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 main
import (
"flag"
"github.com/tamalsaha/chart-fusion/fuse"
"github.com/spf13/cobra"
v "gomodules.xyz/x/version"
"k8s.io/cli-runtime/pkg/genericclioptions"
cliflag "k8s.io/component-base/cli/flag"
cmdutil "k8s.io/kubectl/pkg/cmd/util"
"kmodules.xyz/client-go/logs"
)
func NewRootCmd() *cobra.Command {
var rootCmd = &cobra.Command{
Use: "chart-fusion",
Short: ``,
Long: ``,
DisableAutoGenTag: true,
}
flags := rootCmd.PersistentFlags()
// Normalize all flags that are coming from other packages or pre-configurations
// a.k.a. change all "_" to "-". e.g. glog package
flags.SetNormalizeFunc(cliflag.WordSepNormalizeFunc)
kubeConfigFlags := genericclioptions.NewConfigFlags(true)
kubeConfigFlags.AddFlags(flags)
matchVersionKubeConfigFlags := cmdutil.NewMatchVersionFlags(kubeConfigFlags)
matchVersionKubeConfigFlags.AddFlags(flags)
flags.AddGoFlagSet(flag.CommandLine)
logs.ParseFlags()
f := cmdutil.NewFactory(matchVersionKubeConfigFlags)
rootCmd.AddCommand(v.NewCmdVersion())
rootCmd.AddCommand(NewCmdRun())
rootCmd.AddCommand(NewCmdHelm())
rootCmd.AddCommand(NewCmdFuse(f))
rootCmd.AddCommand(fuse.NewCmdFuse())
rootCmd.AddCommand(NewCmdMerge())
rootCmd.AddCommand(NewCmdAppGen())
rootCmd.AddCommand(NewCmdDocComment())
return rootCmd
}