summaryrefslogtreecommitdiff
path: root/cmd/podman
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/podman')
-rw-r--r--cmd/podman/containers/clone.go9
-rw-r--r--cmd/podman/containers/create.go6
-rw-r--r--cmd/podman/containers/export.go4
-rw-r--r--cmd/podman/containers/run.go4
-rw-r--r--cmd/podman/images/load.go4
-rw-r--r--cmd/podman/images/save.go4
-rw-r--r--cmd/podman/machine/init.go15
-rw-r--r--cmd/podman/machine/set.go7
-rw-r--r--cmd/podman/volumes/unmount.go1
9 files changed, 35 insertions, 19 deletions
diff --git a/cmd/podman/containers/clone.go b/cmd/podman/containers/clone.go
index 8a1473608..6912da1fc 100644
--- a/cmd/podman/containers/clone.go
+++ b/cmd/podman/containers/clone.go
@@ -38,6 +38,9 @@ func cloneFlags(cmd *cobra.Command) {
runFlagName := "run"
flags.BoolVar(&ctrClone.Run, runFlagName, false, "run the new container")
+ forceFlagName := "force"
+ flags.BoolVarP(&ctrClone.Force, forceFlagName, "f", false, "force the existing container to be destroyed")
+
common.DefineCreateFlags(cmd, &ctrClone.CreateOpts, false, true)
}
func init() {
@@ -52,7 +55,7 @@ func init() {
func clone(cmd *cobra.Command, args []string) error {
switch len(args) {
case 0:
- return errors.Wrapf(define.ErrInvalidArg, "Must Specify at least 1 argument")
+ return errors.Wrapf(define.ErrInvalidArg, "must specify at least 1 argument")
case 2:
ctrClone.CreateOpts.Name = args[1]
case 3:
@@ -68,6 +71,10 @@ func clone(cmd *cobra.Command, args []string) error {
ctrClone.RawImageName = rawImageName
}
}
+ if ctrClone.Force && !ctrClone.Destroy {
+ return errors.Wrapf(define.ErrInvalidArg, "cannot set --force without --destroy")
+ }
+
ctrClone.ID = args[0]
ctrClone.CreateOpts.IsClone = true
rep, err := registry.ContainerEngine().ContainerClone(registry.GetContext(), ctrClone)
diff --git a/cmd/podman/containers/create.go b/cmd/podman/containers/create.go
index bbc449a1e..b202e404f 100644
--- a/cmd/podman/containers/create.go
+++ b/cmd/podman/containers/create.go
@@ -286,8 +286,6 @@ func CreateInit(c *cobra.Command, vals entities.ContainerCreateOptions, isInfra
if !isInfra && c.Flag("entrypoint").Changed {
val := c.Flag("entrypoint").Value.String()
vals.Entrypoint = &val
- } else if isInfra && c.Flag("infra-command").Changed {
-
}
// Docker-compatibility: the "-h" flag for run/create is reserved for
@@ -297,7 +295,7 @@ func CreateInit(c *cobra.Command, vals entities.ContainerCreateOptions, isInfra
}
func PullImage(imageName string, cliVals entities.ContainerCreateOptions) (string, error) {
- pullPolicy, err := config.ValidatePullPolicy(cliVals.Pull)
+ pullPolicy, err := config.ParsePullPolicy(cliVals.Pull)
if err != nil {
return "", err
}
@@ -383,7 +381,7 @@ func createPodIfNecessary(cmd *cobra.Command, s *specgen.SpecGenerator, netOpts
podSpec := entities.PodSpec{}
podGen := specgen.NewPodSpecGenerator()
podSpec.PodSpecGen = *podGen
- podGen, err = entities.ToPodSpecGen(*&podSpec.PodSpecGen, &createOptions)
+ podGen, err = entities.ToPodSpecGen(podSpec.PodSpecGen, &createOptions)
if err != nil {
return nil, err
}
diff --git a/cmd/podman/containers/export.go b/cmd/podman/containers/export.go
index 0fed94e86..681df93e0 100644
--- a/cmd/podman/containers/export.go
+++ b/cmd/podman/containers/export.go
@@ -11,7 +11,7 @@ import (
"github.com/containers/podman/v4/pkg/domain/entities"
"github.com/pkg/errors"
"github.com/spf13/cobra"
- "golang.org/x/crypto/ssh/terminal"
+ "golang.org/x/term"
)
var (
@@ -69,7 +69,7 @@ func init() {
func export(cmd *cobra.Command, args []string) error {
if len(exportOpts.Output) == 0 {
file := os.Stdout
- if terminal.IsTerminal(int(file.Fd())) {
+ if term.IsTerminal(int(file.Fd())) {
return errors.Errorf("refusing to export to terminal. Use -o flag or redirect")
}
exportOpts.Output = "/dev/stdout"
diff --git a/cmd/podman/containers/run.go b/cmd/podman/containers/run.go
index 1d98eb3b3..4ad8d3183 100644
--- a/cmd/podman/containers/run.go
+++ b/cmd/podman/containers/run.go
@@ -18,7 +18,7 @@ import (
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
- "golang.org/x/crypto/ssh/terminal"
+ "golang.org/x/term"
)
var (
@@ -112,7 +112,7 @@ func run(cmd *cobra.Command, args []string) error {
var err error
// TODO: Breaking change should be made fatal in next major Release
- if cliVals.TTY && cliVals.Interactive && !terminal.IsTerminal(int(os.Stdin.Fd())) {
+ if cliVals.TTY && cliVals.Interactive && !term.IsTerminal(int(os.Stdin.Fd())) {
logrus.Warnf("The input device is not a TTY. The --tty and --interactive flags might not work properly")
}
diff --git a/cmd/podman/images/load.go b/cmd/podman/images/load.go
index 30f88b02b..6f85fb7e7 100644
--- a/cmd/podman/images/load.go
+++ b/cmd/podman/images/load.go
@@ -16,7 +16,7 @@ import (
"github.com/containers/podman/v4/pkg/util"
"github.com/pkg/errors"
"github.com/spf13/cobra"
- "golang.org/x/crypto/ssh/terminal"
+ "golang.org/x/term"
)
var (
@@ -90,7 +90,7 @@ func load(cmd *cobra.Command, args []string) error {
return err
}
} else {
- if terminal.IsTerminal(int(os.Stdin.Fd())) {
+ if term.IsTerminal(int(os.Stdin.Fd())) {
return errors.Errorf("cannot read from terminal. Use command-line redirection or the --input flag.")
}
outFile, err := ioutil.TempFile(util.Tmpdir(), "podman")
diff --git a/cmd/podman/images/save.go b/cmd/podman/images/save.go
index a9fe675e1..fb642bafd 100644
--- a/cmd/podman/images/save.go
+++ b/cmd/podman/images/save.go
@@ -14,7 +14,7 @@ import (
"github.com/containers/podman/v4/pkg/util"
"github.com/pkg/errors"
"github.com/spf13/cobra"
- "golang.org/x/crypto/ssh/terminal"
+ "golang.org/x/term"
)
var (
@@ -109,7 +109,7 @@ func save(cmd *cobra.Command, args []string) (finalErr error) {
if len(saveOpts.Output) == 0 {
saveOpts.Quiet = true
fi := os.Stdout
- if terminal.IsTerminal(int(fi.Fd())) {
+ if term.IsTerminal(int(fi.Fd())) {
return errors.Errorf("refusing to save to terminal. Use -o flag or redirect")
}
pipePath, cleanup, err := setupPipe()
diff --git a/cmd/podman/machine/init.go b/cmd/podman/machine/init.go
index 2d0afbf05..06c1f7248 100644
--- a/cmd/podman/machine/init.go
+++ b/cmd/podman/machine/init.go
@@ -12,6 +12,7 @@ import (
"github.com/containers/podman/v4/pkg/machine"
"github.com/pkg/errors"
"github.com/spf13/cobra"
+ "github.com/spf13/pflag"
)
var (
@@ -106,8 +107,18 @@ func init() {
flags.StringVar(&initOpts.IgnitionPath, IgnitionPathFlagName, "", "Path to ignition file")
_ = initCmd.RegisterFlagCompletionFunc(IgnitionPathFlagName, completion.AutocompleteDefault)
- rootfulFlagName := "rootful"
- flags.BoolVar(&initOpts.Rootful, rootfulFlagName, false, "Whether this machine should prefer rootful container execution")
+ rootfullFlagName := "rootfull"
+ flags.BoolVar(&initOpts.Rootfull, rootfullFlagName, false, "Whether this machine should prefer rootfull container execution")
+ flags.SetNormalizeFunc(aliasFlags)
+}
+
+// aliasFlags is a function to handle backwards compatibility with old flags
+func aliasFlags(f *pflag.FlagSet, name string) pflag.NormalizedName {
+ switch name {
+ case "rootful":
+ name = "rootfull"
+ }
+ return pflag.NormalizedName(name)
}
// TODO should we allow for a users to append to the qemu cmdline?
diff --git a/cmd/podman/machine/set.go b/cmd/podman/machine/set.go
index 4c15f1de1..b1dfb51da 100644
--- a/cmd/podman/machine/set.go
+++ b/cmd/podman/machine/set.go
@@ -17,7 +17,7 @@ var (
Long: "Sets an updatable virtual machine setting",
RunE: setMachine,
Args: cobra.MaximumNArgs(1),
- Example: `podman machine set --rootful=false`,
+ Example: `podman machine set --rootfull=false`,
ValidArgsFunction: completion.AutocompleteNone,
}
)
@@ -33,8 +33,9 @@ func init() {
})
flags := setCmd.Flags()
- rootfulFlagName := "rootful"
- flags.BoolVar(&setOpts.Rootful, rootfulFlagName, false, "Whether this machine should prefer rootful container execution")
+ rootfullFlagName := "rootfull"
+ flags.BoolVar(&setOpts.Rootfull, rootfullFlagName, false, "Whether this machine should prefer rootfull container execution")
+ flags.SetNormalizeFunc(aliasFlags)
}
func setMachine(cmd *cobra.Command, args []string) error {
diff --git a/cmd/podman/volumes/unmount.go b/cmd/podman/volumes/unmount.go
index dd0cebc06..af79e49ef 100644
--- a/cmd/podman/volumes/unmount.go
+++ b/cmd/podman/volumes/unmount.go
@@ -37,7 +37,6 @@ func volumeUnmount(cmd *cobra.Command, args []string) error {
return err
}
for _, r := range reports {
- var errs utils.OutputErrors
if r.Err == nil {
fmt.Println(r.Id)
} else {