-
Notifications
You must be signed in to change notification settings - Fork 0
/
root.go
41 lines (34 loc) · 801 Bytes
/
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
package cmd
import (
"errors"
"github.com/spf13/cobra"
"io"
"os"
)
const rootCmdUsage = `
The val plugin helps you to get values from an old release
`
var settings *EnvSettings
//NewRootCmd creates a root cmd
func NewRootCmd(out io.Writer, args []string) *cobra.Command {
cmd := &cobra.Command{
Use: "val",
Short: "Fetch values from previous release",
Long: rootCmdUsage,
SilenceUsage: true,
Args: func(cmd *cobra.Command, args []string) error {
if len(args) > 1 {
return errors.New("no argument accepted")
}
return nil
},
}
flags := cmd.PersistentFlags()
flags.Parse(args)
settings = new(EnvSettings)
if ctx := os.Getenv("HELM_KUBECONTEXT"); ctx != "" {
settings.KubeContext = ctx
}
cmd.AddCommand(NewFetchCmd(out))
return cmd
}