MCPcopy
hub / github.com/kubevela/kubevela / WithNamespaceFlag

Method WithNamespaceFlag

pkg/cmd/builder.go:117–131  ·  view source on GitHub ↗

WithNamespaceFlag add namespace flag to the command, by default, it will also add env flag to the command

(options ...NamespaceFlagOption)

Source from the content-addressed store, hash-verified

115
116// WithNamespaceFlag add namespace flag to the command, by default, it will also add env flag to the command
117func (builder *Builder) WithNamespaceFlag(options ...NamespaceFlagOption) *Builder {
118 cfg := newNamespaceFlagOptions(options...)
119 builder.cmd.Flags().StringP(flagNamespace, "n", "", cfg.usage)
120 if cfg.completion {
121 cmdutil.CheckErr(builder.cmd.RegisterFlagCompletionFunc(
122 flagNamespace,
123 func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
124 return GetNamespacesForCompletion(cmd.Context(), builder.f, toComplete)
125 }))
126 }
127 if cfg.loadEnv {
128 return builder.WithEnvFlag()
129 }
130 return builder
131}
132
133// WithEnvFlag add env flag to the command
134func (builder *Builder) WithEnvFlag() *Builder {

Callers 8

NewUpCommandFunction · 0.80
NewKubeApplyCommandFunction · 0.80
NewKubeDeleteCommandFunction · 0.80
NewDeleteCommandFunction · 0.80
NewGenKubeConfigCommandFunction · 0.80
NewListPrivilegesCommandFunction · 0.80
NewAdoptCommandFunction · 0.80

Calls 4

WithEnvFlagMethod · 0.95
newNamespaceFlagOptionsFunction · 0.85
FlagsMethod · 0.80

Tested by

no test coverage detected