/
flag.go
33 lines (25 loc) · 870 Bytes
/
flag.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
package clusters
import (
"github.com/spf13/cobra"
"k8s.io/cli-runtime/pkg/genericclioptions"
)
const (
flagAllNamespaces = "all-namespaces"
)
type flag struct {
AllNamespaces bool
config genericclioptions.RESTClientGetter
print *genericclioptions.PrintFlags
}
func (f *flag) Init(cmd *cobra.Command) {
cmd.Flags().BoolVarP(&f.AllNamespaces, flagAllNamespaces, "A", false, "If present, list the requested object(s) across all namespaces. Namespace in current context is ignored even if specified with --namespace.")
f.config = genericclioptions.NewConfigFlags(true)
f.print = genericclioptions.NewPrintFlags("")
// Merging current command flags and config flags,
// to be able to override kubectl-specific ones.
f.config.(*genericclioptions.ConfigFlags).AddFlags(cmd.Flags())
f.print.AddFlags(cmd)
}
func (f *flag) Validate() error {
return nil
}