/
get_cluster.go
55 lines (43 loc) · 1.02 KB
/
get_cluster.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
49
50
51
52
53
54
55
package ocean
import (
"github.com/spf13/cobra"
"github.com/spf13/pflag"
)
type (
CmdGetCluster struct {
cmd *cobra.Command
opts CmdGetClusterOptions
}
CmdGetClusterOptions struct {
*CmdGetOptions
}
)
func NewCmdGetCluster(opts *CmdGetOptions) *cobra.Command {
return newCmdGetCluster(opts).cmd
}
func newCmdGetCluster(opts *CmdGetOptions) *CmdGetCluster {
var cmd CmdGetCluster
cmd.cmd = &cobra.Command{
Use: "cluster",
Short: "Display one or many clusters",
SilenceErrors: true,
SilenceUsage: true,
}
cmd.opts.Init(cmd.cmd.PersistentFlags(), opts)
cmd.initSubCommands()
return &cmd
}
func (x *CmdGetCluster) initSubCommands() {
commands := []func(*CmdGetClusterOptions) *cobra.Command{
NewCmdGetClusterKubernetes,
}
for _, cmd := range commands {
x.cmd.AddCommand(cmd(&x.opts))
}
}
func (x *CmdGetClusterOptions) Init(fs *pflag.FlagSet, opts *CmdGetOptions) {
x.CmdGetOptions = opts
}
func (x *CmdGetClusterOptions) Validate() error {
return x.CmdGetOptions.Validate()
}