MCPcopy
hub / github.com/kubeedge/kubeedge / NewCSIDriverCommand

Function NewCSIDriverCommand

cloud/cmd/csidriver/app/server.go:35–79  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

33)
34
35func NewCSIDriverCommand() *cobra.Command {
36 opts := options.NewCSIDriverOptions()
37 cmd := &cobra.Command{
38 Use: "csidriver",
39 Long: `CSI Driver from KubeEdge: this is more like CSI Driver proxy,
40 and it implements all of the CSI Identity and Controller interfaces.
41 It sends messages to CloudHub which will forward to edge. Actually all of the actions
42 about the Volume Lifecycle are executed in the CSI Driver from Vendor at edge`,
43 Run: func(cmd *cobra.Command, args []string) {
44 verflag.PrintAndExitIfRequested()
45 flag.PrintFlags(cmd.Flags())
46
47 // To help debugging, immediately log version
48 klog.Infof("Version: %+v", version.Get())
49
50 // start driver
51 driver, err := csidriver.NewCSIDriver(opts)
52 if err != nil {
53 klog.Errorf("failed to initialize driver: %s", err.Error())
54 return
55 }
56 driver.Run()
57 },
58 }
59 fs := cmd.Flags()
60 namedFs := opts.Flags()
61 verflag.AddFlags(namedFs.FlagSet("global"))
62 globalflag.AddGlobalFlags(namedFs.FlagSet("global"), cmd.Name())
63 for _, f := range namedFs.FlagSets {
64 fs.AddFlagSet(f)
65 }
66
67 usageFmt := "Usage:\n %s\n"
68 cols, _, _ := term.TerminalSize(cmd.OutOrStdout())
69 cmd.SetUsageFunc(func(cmd *cobra.Command) error {
70 fmt.Fprintf(cmd.OutOrStderr(), usageFmt, cmd.UseLine())
71 cliflag.PrintSections(cmd.OutOrStderr(), namedFs, cols)
72 return nil
73 })
74 cmd.SetHelpFunc(func(cmd *cobra.Command, args []string) {
75 fmt.Fprintf(cmd.OutOrStdout(), "%s\n\n"+usageFmt, cmd.Long, cmd.UseLine())
76 cliflag.PrintSections(cmd.OutOrStdout(), namedFs, cols)
77 })
78 return cmd
79}

Callers 2

mainFunction · 0.92
TestNewCSIDriverCommandFunction · 0.85

Calls 10

FlagsMethod · 0.95
RunMethod · 0.95
NewCSIDriverOptionsFunction · 0.92
PrintAndExitIfRequestedFunction · 0.92
PrintFlagsFunction · 0.92
GetFunction · 0.92
NewCSIDriverFunction · 0.92
AddFlagsFunction · 0.92
ErrorMethod · 0.65
NameMethod · 0.65

Tested by 1

TestNewCSIDriverCommandFunction · 0.68