...
1
2
3
4 package initcmd
5
6 import (
7 "github.com/spf13/cobra"
8 "k8s.io/cli-runtime/pkg/genericclioptions"
9 cmdutil "k8s.io/kubectl/pkg/cmd/util"
10 "k8s.io/kubectl/pkg/util/i18n"
11 "sigs.k8s.io/cli-utils/pkg/config"
12 )
13
14
15 type InitRunner struct {
16 Command *cobra.Command
17 InitOptions *config.InitOptions
18 }
19
20
21
22 func GetInitRunner(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *InitRunner {
23 io := config.NewInitOptions(f, ioStreams)
24 cmd := &cobra.Command{
25 Use: "init DIRECTORY",
26 DisableFlagsInUseLine: true,
27 Short: i18n.T("Create a prune manifest ConfigMap as a inventory object"),
28 RunE: func(cmd *cobra.Command, args []string) error {
29 err := io.Complete(args)
30 if err != nil {
31 return err
32 }
33 return io.Run()
34 },
35 }
36 cmd.Flags().StringVarP(&io.InventoryID, "inventory-id", "i", "", "Identifier for group of applied resources. Must be composed of valid label characters.")
37 i := &InitRunner{
38 Command: cmd,
39 InitOptions: io,
40 }
41 return i
42 }
43
44
45 func NewCmdInit(f cmdutil.Factory, ioStreams genericclioptions.IOStreams) *cobra.Command {
46 return GetInitRunner(f, ioStreams).Command
47 }
48
View as plain text