MCPcopy Index your code
hub / github.com/linuxkit/linuxkit / runCmd

Function runCmd

src/cmd/linuxkit/run.go:16–73  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

14)
15
16func runCmd() *cobra.Command {
17
18 cmd := &cobra.Command{
19 Use: "run",
20 Short: "run a VM image",
21 Long: `Run a VM image.
22
23 'backend' specifies the run backend.
24 If the backend is not specified, the platform specific default will be used.
25
26 'prefix' specifies the path to the image.
27 If the image is not specified, the default is './image'.
28 `,
29 Example: `run [options] [backend] [prefix]`,
30 RunE: func(cmd *cobra.Command, args []string) error {
31 var target string
32 switch runtime.GOOS {
33 case "darwin":
34 target = "virtualization"
35 case "linux":
36 target = "qemu"
37 case "windows":
38 target = "hyperv"
39 default:
40 return fmt.Errorf("there currently is no default 'run' backend for your platform")
41 }
42 children := cmd.Commands()
43 for _, child := range children {
44 if child.Name() == target {
45 return child.RunE(cmd, args)
46 }
47 }
48
49 return fmt.Errorf("could not find default for your platform: %s", target)
50 },
51 }
52
53 // Please keep cases in alphabetical order
54 cmd.AddCommand(runAWSCmd())
55 cmd.AddCommand(runAzureCmd())
56 cmd.AddCommand(runGCPCmd())
57 cmd.AddCommand(runHyperkitCmd())
58 cmd.AddCommand(runVirtualizationFrameworkCmd())
59 cmd.AddCommand(runHyperVCmd())
60 cmd.AddCommand(runOpenStackCmd())
61 cmd.AddCommand(runEquinixMetalCmd())
62 cmd.AddCommand(runQEMUCmd())
63 cmd.AddCommand(runScalewayCmd())
64 cmd.AddCommand(runVMWareCmd())
65 cmd.AddCommand(runVBoxCmd())
66 cmd.AddCommand(runVCenterCmd())
67
68 cmd.PersistentFlags().IntVar(&cpus, "cpus", 1, "Number of CPUs")
69 cmd.PersistentFlags().IntVar(&mem, "mem", 1024, "Amount of memory in MB")
70 cmd.PersistentFlags().Var(&disks, "disk", "Disk config. [file=]path[,size=1G]")
71
72 return cmd
73}

Callers 1

newCmdFunction · 0.85

Calls 13

runAWSCmdFunction · 0.85
runAzureCmdFunction · 0.85
runGCPCmdFunction · 0.85
runHyperkitCmdFunction · 0.85
runHyperVCmdFunction · 0.85
runOpenStackCmdFunction · 0.85
runEquinixMetalCmdFunction · 0.85
runQEMUCmdFunction · 0.85
runScalewayCmdFunction · 0.85
runVMWareCmdFunction · 0.85
runVBoxCmdFunction · 0.85

Tested by

no test coverage detected