diff options
author | Daniel J Walsh <dwalsh@redhat.com> | 2021-09-18 06:21:07 -0400 |
---|---|---|
committer | Daniel J Walsh <dwalsh@redhat.com> | 2021-09-19 05:53:08 -0400 |
commit | 74ad05396b7c988856c3c2d3af88f3725ef29775 (patch) | |
tree | 405cdd2035684e9293766350fe6b46f617f30985 /cmd | |
parent | ddb384451147c4ef9d0307be0cc8dbad6d94970c (diff) | |
download | podman-74ad05396b7c988856c3c2d3af88f3725ef29775.tar.gz podman-74ad05396b7c988856c3c2d3af88f3725ef29775.tar.bz2 podman-74ad05396b7c988856c3c2d3af88f3725ef29775.zip |
Add podman machine init --now option
Once we have this option, the new documentation from users becomes
a little simpler.
brew install podman
podman machine init --now
podman run ...
--now option is based off of `systemctl enable XYZ.service --now`
[NO TESTS NEEDED] The infrastructure has not been setup yet to test
podman machine init.
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/podman/machine/init.go | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/cmd/podman/machine/init.go b/cmd/podman/machine/init.go index ec44a707d..19f31d1a6 100644 --- a/cmd/podman/machine/init.go +++ b/cmd/podman/machine/init.go @@ -3,6 +3,8 @@ package machine import ( + "fmt" + "github.com/containers/common/pkg/completion" "github.com/containers/podman/v3/cmd/podman/registry" "github.com/containers/podman/v3/pkg/machine" @@ -26,6 +28,7 @@ var ( var ( initOpts = machine.InitOptions{} defaultMachineName = "podman-machine-default" + now bool ) func init() { @@ -61,6 +64,12 @@ func init() { ) _ = initCmd.RegisterFlagCompletionFunc(memoryFlagName, completion.AutocompleteNone) + flags.BoolVar( + &now, + "now", false, + "Start machine now", + ) + ImagePathFlagName := "image-path" flags.StringVar(&initOpts.ImagePath, ImagePathFlagName, cfg.Engine.MachineImage, "Path to qcow image") _ = initCmd.RegisterFlagCompletionFunc(ImagePathFlagName, completion.AutocompleteDefault) @@ -91,5 +100,15 @@ func initMachine(cmd *cobra.Command, args []string) error { if err != nil { return err } - return vm.Init(initOpts) + err = vm.Init(initOpts) + if err != nil { + return err + } + if now { + err = vm.Start(initOpts.Name, machine.StartOptions{}) + if err == nil { + fmt.Printf("Machine %q started successfully\n", initOpts.Name) + } + } + return err } |