summaryrefslogtreecommitdiff
path: root/cmd/podman/machine
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2021-03-22 13:29:25 -0500
committerbaude <bbaude@redhat.com>2021-03-25 11:02:33 -0500
commit4ab8a6f67eb9de0de40d478cb0cbec05b1b725c0 (patch)
tree00743bf608cc5700fe8a7fca1bb3b0f3a4457b7d /cmd/podman/machine
parente7661137373b5f87bf6ec45e32326821b172ce7b (diff)
downloadpodman-4ab8a6f67eb9de0de40d478cb0cbec05b1b725c0.tar.gz
podman-4ab8a6f67eb9de0de40d478cb0cbec05b1b725c0.tar.bz2
podman-4ab8a6f67eb9de0de40d478cb0cbec05b1b725c0.zip
Improvements for machine
clean up ci failures and add appropriate arch,os exclusion tags Signed-off-by: baude <bbaude@redhat.com>
Diffstat (limited to 'cmd/podman/machine')
-rw-r--r--cmd/podman/machine/create.go28
-rw-r--r--cmd/podman/machine/machine.go4
-rw-r--r--cmd/podman/machine/machine_unsupported.go5
-rw-r--r--cmd/podman/machine/remove.go (renamed from cmd/podman/machine/destroy.go)31
-rw-r--r--cmd/podman/machine/ssh.go9
-rw-r--r--cmd/podman/machine/start.go2
-rw-r--r--cmd/podman/machine/stop.go2
7 files changed, 41 insertions, 40 deletions
diff --git a/cmd/podman/machine/create.go b/cmd/podman/machine/create.go
index 04c5e9e65..1da34327a 100644
--- a/cmd/podman/machine/create.go
+++ b/cmd/podman/machine/create.go
@@ -1,3 +1,5 @@
+// +build amd64,linux amd64,darwin arm64,darwin
+
package machine
import (
@@ -6,17 +8,16 @@ import (
"github.com/containers/podman/v3/pkg/domain/entities"
"github.com/containers/podman/v3/pkg/machine"
"github.com/containers/podman/v3/pkg/machine/qemu"
- "github.com/pkg/errors"
"github.com/spf13/cobra"
)
var (
createCmd = &cobra.Command{
- Use: "create [options] NAME",
+ Use: "create [options] [NAME]",
Short: "Create a vm",
- Long: "Create a virtual machine for Podman to run on. Virtual machines are used to run Podman on Macs. ",
+ Long: "Create a virtual machine for Podman to run on. Virtual machines are used to run Podman.",
RunE: create,
- Args: cobra.NoArgs,
+ Args: cobra.MaximumNArgs(1),
Example: `podman machine create myvm`,
ValidArgsFunction: completion.AutocompleteNone,
}
@@ -32,7 +33,8 @@ type CreateCLIOptions struct {
}
var (
- createOpts = CreateCLIOptions{}
+ createOpts = CreateCLIOptions{}
+ defaultMachineName string = "podman-machine-default"
)
func init() {
@@ -59,14 +61,6 @@ func init() {
)
_ = createCmd.RegisterFlagCompletionFunc(memoryFlagName, completion.AutocompleteNone)
- deviceFlagName := "name"
- flags.StringVar(
- &createOpts.Name,
- deviceFlagName, "",
- "set vm name",
- )
- _ = createCmd.RegisterFlagCompletionFunc(deviceFlagName, completion.AutocompleteDefault)
-
ImagePathFlagName := "image-path"
flags.StringVar(&createOpts.ImagePath, ImagePathFlagName, "", "Path to qcow image")
_ = createCmd.RegisterFlagCompletionFunc(ImagePathFlagName, completion.AutocompleteDefault)
@@ -78,9 +72,9 @@ func init() {
// TODO should we allow for a users to append to the qemu cmdline?
func create(cmd *cobra.Command, args []string) error {
- // TODO add ability to create default, not name required
- if len(createOpts.Name) < 1 {
- return errors.New("required --name not provided")
+ createOpts.Name = defaultMachineName
+ if len(args) > 0 {
+ createOpts.Name = args[0]
}
vmOpts := machine.CreateOptions{
CPUS: createOpts.CPUS,
@@ -95,8 +89,6 @@ func create(cmd *cobra.Command, args []string) error {
err error
)
switch vmType {
- case "foobar":
- // do nothing
default: // qemu is the default
vm, err = qemu.NewMachine(vmOpts)
}
diff --git a/cmd/podman/machine/machine.go b/cmd/podman/machine/machine.go
index ce5a3b889..ed284ee10 100644
--- a/cmd/podman/machine/machine.go
+++ b/cmd/podman/machine/machine.go
@@ -1,3 +1,5 @@
+// +build amd64,linux amd64,darwin arm64,darwin
+
package machine
import (
@@ -15,7 +17,7 @@ var (
machineCmd = &cobra.Command{
Use: "machine",
Short: "Manage a virtual machine",
- Long: "Manage a virtual machine. Virtual machines are used to run Podman on Macs.",
+ Long: "Manage a virtual machine. Virtual machines are used to run Podman.",
PersistentPreRunE: noOp,
PersistentPostRunE: noOp,
RunE: validate.SubCommandExists,
diff --git a/cmd/podman/machine/machine_unsupported.go b/cmd/podman/machine/machine_unsupported.go
new file mode 100644
index 000000000..cb1636419
--- /dev/null
+++ b/cmd/podman/machine/machine_unsupported.go
@@ -0,0 +1,5 @@
+// +build !amd64 arm64,linux amd64,windows
+
+package machine
+
+func init() {}
diff --git a/cmd/podman/machine/destroy.go b/cmd/podman/machine/remove.go
index ab23d607d..f6ce9e326 100644
--- a/cmd/podman/machine/destroy.go
+++ b/cmd/podman/machine/remove.go
@@ -1,3 +1,5 @@
+// +build amd64,linux amd64,darwin arm64,darwin
+
package machine
import (
@@ -7,7 +9,6 @@ import (
"strings"
"github.com/containers/common/pkg/completion"
- "github.com/containers/podman/v3/cmd/podman/common"
"github.com/containers/podman/v3/cmd/podman/registry"
"github.com/containers/podman/v3/pkg/domain/entities"
"github.com/containers/podman/v3/pkg/machine"
@@ -16,47 +17,43 @@ import (
)
var (
- destroyCmd = &cobra.Command{
- Use: "destroy [options] NAME",
- Short: "Destroy an existing machine",
- Long: "Destroy an existing machine ",
- RunE: destroy,
+ removeCmd = &cobra.Command{
+ Use: "remove [options] NAME",
+ Short: "Remove an existing machine",
+ Long: "Remove an existing machine ",
+ RunE: remove,
Args: cobra.ExactArgs(1),
- Example: `podman machine destroy myvm`,
+ Example: `podman machine remove myvm`,
ValidArgsFunction: completion.AutocompleteNone,
}
)
var (
- destoryOptions machine.DestroyOptions
+ destoryOptions machine.RemoveOptions
)
func init() {
registry.Commands = append(registry.Commands, registry.CliCommand{
Mode: []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
- Command: destroyCmd,
+ Command: removeCmd,
Parent: machineCmd,
})
- flags := destroyCmd.Flags()
+ flags := removeCmd.Flags()
formatFlagName := "force"
- flags.BoolVar(&destoryOptions.Force, formatFlagName, false, "Do not prompt before destroying")
- _ = destroyCmd.RegisterFlagCompletionFunc(formatFlagName, common.AutocompleteJSONFormat)
+ flags.BoolVar(&destoryOptions.Force, formatFlagName, false, "Do not prompt before removeing")
keysFlagName := "save-keys"
flags.BoolVar(&destoryOptions.SaveKeys, keysFlagName, false, "Do not delete SSH keys")
- _ = destroyCmd.RegisterFlagCompletionFunc(keysFlagName, common.AutocompleteJSONFormat)
ignitionFlagName := "save-ignition"
flags.BoolVar(&destoryOptions.SaveIgnition, ignitionFlagName, false, "Do not delete ignition file")
- _ = destroyCmd.RegisterFlagCompletionFunc(ignitionFlagName, common.AutocompleteJSONFormat)
imageFlagName := "save-image"
flags.BoolVar(&destoryOptions.SaveImage, imageFlagName, false, "Do not delete the image file")
- _ = destroyCmd.RegisterFlagCompletionFunc(imageFlagName, common.AutocompleteJSONFormat)
}
-func destroy(cmd *cobra.Command, args []string) error {
+func remove(cmd *cobra.Command, args []string) error {
var (
err error
vm machine.VM
@@ -69,7 +66,7 @@ func destroy(cmd *cobra.Command, args []string) error {
if err != nil {
return err
}
- confirmationMessage, doIt, err := vm.Destroy(args[0], machine.DestroyOptions{})
+ confirmationMessage, doIt, err := vm.Remove(args[0], machine.RemoveOptions{})
if err != nil {
return err
}
diff --git a/cmd/podman/machine/ssh.go b/cmd/podman/machine/ssh.go
index 32483f731..a7111a195 100644
--- a/cmd/podman/machine/ssh.go
+++ b/cmd/podman/machine/ssh.go
@@ -1,7 +1,9 @@
+// +build amd64,linux amd64,darwin arm64,darwin
+
package machine
import (
- "github.com/containers/common/pkg/completion"
+ "github.com/containers/podman/v3/cmd/podman/common"
"github.com/containers/podman/v3/cmd/podman/registry"
"github.com/containers/podman/v3/pkg/domain/entities"
"github.com/containers/podman/v3/pkg/machine"
@@ -14,13 +16,13 @@ var (
sshCmd = &cobra.Command{
Use: "ssh [options] NAME [COMMAND [ARG ...]]",
Short: "SSH into a virtual machine",
- Long: "SSH into a podman-managed virtual machine ",
+ Long: "SSH into a virtual machine ",
RunE: ssh,
Args: cobra.MinimumNArgs(1),
Example: `podman machine ssh myvm
podman machine ssh -e myvm echo hello`,
- ValidArgsFunction: completion.AutocompleteNone,
+ ValidArgsFunction: common.AutocompleteMachineSSH,
}
)
@@ -38,7 +40,6 @@ func init() {
flags := sshCmd.Flags()
executeFlagName := "execute"
flags.BoolVarP(&sshOpts.Execute, executeFlagName, "e", false, "Execute command from args")
- _ = sshCmd.RegisterFlagCompletionFunc(executeFlagName, completion.AutocompleteDefault)
}
func ssh(cmd *cobra.Command, args []string) error {
diff --git a/cmd/podman/machine/start.go b/cmd/podman/machine/start.go
index 762639358..44ade2850 100644
--- a/cmd/podman/machine/start.go
+++ b/cmd/podman/machine/start.go
@@ -1,3 +1,5 @@
+// +build amd64,linux amd64,darwin arm64,darwin
+
package machine
import (
diff --git a/cmd/podman/machine/stop.go b/cmd/podman/machine/stop.go
index b6585c296..35fd4ff95 100644
--- a/cmd/podman/machine/stop.go
+++ b/cmd/podman/machine/stop.go
@@ -1,3 +1,5 @@
+// +build amd64,linux amd64,darwin arm64,darwin
+
package machine
import (