/
rollout.go
58 lines (46 loc) · 1.03 KB
/
rollout.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
56
57
58
package ocean
import (
"github.com/spf13/cobra"
"github.com/spf13/pflag"
)
type (
CmdRollout struct {
cmd *cobra.Command
opts CmdRolloutOptions
}
CmdRolloutOptions struct {
*CmdOptions
}
)
func NewCmdRollout(opts *CmdOptions) *cobra.Command {
return newCmdRollout(opts).cmd
}
func newCmdRollout(opts *CmdOptions) *CmdRollout {
var cmd CmdRollout
cmd.cmd = &cobra.Command{
Use: "rollout",
Short: "Manage the rollout of a resource",
SilenceErrors: true,
SilenceUsage: true,
}
cmd.opts.Init(cmd.cmd.PersistentFlags(), opts)
cmd.initSubCommands()
return &cmd
}
func (x *CmdRollout) initSubCommands() {
commands := []func(*CmdRolloutOptions) *cobra.Command{
NewCmdRolloutStart,
NewCmdRolloutStop,
NewCmdRolloutStatus,
NewCmdRolloutHistory,
}
for _, cmd := range commands {
x.cmd.AddCommand(cmd(&x.opts))
}
}
func (x *CmdRolloutOptions) Init(fs *pflag.FlagSet, opts *CmdOptions) {
x.CmdOptions = opts
}
func (x *CmdRolloutOptions) Validate() error {
return x.CmdOptions.Validate()
}