-
Notifications
You must be signed in to change notification settings - Fork 13
/
cmd.go
44 lines (35 loc) · 1.28 KB
/
cmd.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
// Copyright Contributors to the Open Cluster Management project
package cluster
import (
"fmt"
genericclioptionscm "github.com/stolostron/cm-cli/pkg/genericclioptions"
cmdutil "k8s.io/kubectl/pkg/cmd/util"
"github.com/spf13/cobra"
"github.com/stolostron/cm-cli/pkg/helpers"
"k8s.io/cli-runtime/pkg/genericclioptions"
)
const (
example = `
# get the config for a cluster
%[1]s get config cluster <cluster_name> [--output-file <file_name]
`
)
// NewCmd ...
func NewCmd(cmFlags *genericclioptionscm.CMFlags, streams genericclioptions.IOStreams) *cobra.Command {
o := newOptions(cmFlags, streams)
cmd := &cobra.Command{
Use: "cluster",
Aliases: []string{"clusters"},
DisableFlagsInUseLine: true,
Short: "Display the config of a cluster",
Example: fmt.Sprintf(example, helpers.GetExampleHeader()),
Run: func(cmd *cobra.Command, args []string) {
cmdutil.CheckErr(o.complete(cmd, args))
cmdutil.CheckErr(o.validate())
cmdutil.CheckErr(o.run())
},
}
cmd.Flags().StringVar(&o.outputFile, "output-file", "", "The config will be copied in the specified file")
cmd.Flags().BoolVar(&o.withoutCredentials, "without-credentials", false, "If set the platform credentials will be not inserted in the config")
return cmd
}