MCPcopy
hub / github.com/operator-framework/operator-sdk / NewCmd

Function NewCmd

internal/cmd/helm-operator/run/cmd.go:69–93  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

67}
68
69func NewCmd() *cobra.Command {
70 f := &flags.Flags{}
71 zapfs := flag.NewFlagSet("zap", flag.ExitOnError)
72 opts := &zapf.Options{}
73 opts.BindFlags(zapfs)
74
75 cmd := &cobra.Command{
76 Use: "run",
77 Short: "Run the operator",
78 Args: func(cmd *cobra.Command, _ []string) error {
79 if cmd.Flag("metrics-require-rbac").Value.String() == "true" && cmd.Flag("metrics-secure").Value.String() == "false" {
80 return errors.New("--metrics-secure flag is required when --metrics-require-rbac is present")
81 }
82 return nil
83 },
84 Run: func(cmd *cobra.Command, _ []string) {
85 logf.SetLogger(zapf.New(zapf.UseFlagOptions(opts)))
86 run(cmd, f)
87 },
88 }
89
90 f.AddTo(cmd.Flags())
91 cmd.Flags().AddGoFlagSet(zapfs)
92 return cmd
93}
94
95func run(cmd *cobra.Command, f *flags.Flags) {
96 printVersion()

Callers 1

mainFunction · 0.92

Calls 4

AddToMethod · 0.95
runFunction · 0.70
BindFlagsMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected