summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/podman/common/create_opts.go2
-rw-r--r--cmd/podman/containers/create.go19
-rw-r--r--cmd/podman/containers/ps.go5
-rw-r--r--cmd/podman/containers/run.go2
-rw-r--r--cmd/podman/machine/init.go17
-rw-r--r--cmd/podman/machine/set.go7
-rw-r--r--cmd/podman/root.go4
-rw-r--r--cmd/podman/system/connection/add.go4
8 files changed, 28 insertions, 32 deletions
diff --git a/cmd/podman/common/create_opts.go b/cmd/podman/common/create_opts.go
index 7b7626040..16f193b03 100644
--- a/cmd/podman/common/create_opts.go
+++ b/cmd/podman/common/create_opts.go
@@ -347,7 +347,7 @@ func ContainerCreateToContainerCLIOpts(cc handlers.CreateContainerConfig, rtc *c
cliOpts.Volume = append(cliOpts.Volume, vol)
// Extract the destination so we don't add duplicate mounts in
// the volumes phase.
- splitVol := strings.SplitN(vol, ":", 3)
+ splitVol := specgen.SplitVolumeString(vol)
switch len(splitVol) {
case 1:
volDestinations[vol] = true
diff --git a/cmd/podman/containers/create.go b/cmd/podman/containers/create.go
index b202e404f..29e138e30 100644
--- a/cmd/podman/containers/create.go
+++ b/cmd/podman/containers/create.go
@@ -142,7 +142,7 @@ func create(cmd *cobra.Command, args []string) error {
}
s.RawImageName = rawImageName
- if _, err := createPodIfNecessary(cmd, s, cliVals.Net); err != nil {
+ if err := createPodIfNecessary(cmd, s, cliVals.Net); err != nil {
return err
}
@@ -345,13 +345,13 @@ func PullImage(imageName string, cliVals entities.ContainerCreateOptions) (strin
// createPodIfNecessary automatically creates a pod when requested. if the pod name
// has the form new:ID, the pod ID is created and the name in the spec generator is replaced
// with ID.
-func createPodIfNecessary(cmd *cobra.Command, s *specgen.SpecGenerator, netOpts *entities.NetOptions) (*entities.PodCreateReport, error) {
+func createPodIfNecessary(cmd *cobra.Command, s *specgen.SpecGenerator, netOpts *entities.NetOptions) error {
if !strings.HasPrefix(s.Pod, "new:") {
- return nil, nil
+ return nil
}
podName := strings.Replace(s.Pod, "new:", "", 1)
if len(podName) < 1 {
- return nil, errors.Errorf("new pod name must be at least one character")
+ return errors.Errorf("new pod name must be at least one character")
}
var err error
@@ -359,7 +359,7 @@ func createPodIfNecessary(cmd *cobra.Command, s *specgen.SpecGenerator, netOpts
if cliVals.UserNS != "" {
uns, err = specgen.ParseNamespace(cliVals.UserNS)
if err != nil {
- return nil, err
+ return err
}
}
createOptions := entities.PodCreateOptions{
@@ -383,7 +383,7 @@ func createPodIfNecessary(cmd *cobra.Command, s *specgen.SpecGenerator, netOpts
podSpec.PodSpecGen = *podGen
podGen, err = entities.ToPodSpecGen(podSpec.PodSpecGen, &createOptions)
if err != nil {
- return nil, err
+ return err
}
infraOpts := entities.NewInfraContainerCreateOptions()
@@ -391,14 +391,15 @@ func createPodIfNecessary(cmd *cobra.Command, s *specgen.SpecGenerator, netOpts
infraOpts.Quiet = true
infraOpts.Hostname, err = cmd.Flags().GetString("hostname")
if err != nil {
- return nil, err
+ return err
}
podGen.InfraContainerSpec = specgen.NewSpecGenerator("", false)
podGen.InfraContainerSpec.NetworkOptions = podGen.NetworkOptions
err = specgenutil.FillOutSpecGen(podGen.InfraContainerSpec, &infraOpts, []string{})
if err != nil {
- return nil, err
+ return err
}
podSpec.PodSpecGen = *podGen
- return registry.ContainerEngine().PodCreate(context.Background(), podSpec)
+ _, err = registry.ContainerEngine().PodCreate(context.Background(), podSpec)
+ return err
}
diff --git a/cmd/podman/containers/ps.go b/cmd/podman/containers/ps.go
index 91bb9bdb7..4adae30c2 100644
--- a/cmd/podman/containers/ps.go
+++ b/cmd/podman/containers/ps.go
@@ -363,6 +363,11 @@ func (l psReporter) State() string {
state = fmt.Sprintf("Exited (%d) %s ago", l.ExitCode, t)
default:
// Need to capitalize the first letter to match Docker.
+
+ // strings.Title is deprecated since go 1.18
+ // However for our use case it is still fine. The recommended replacement
+ // is adding about 400kb binary size so lets keep using this for now.
+ //nolint:staticcheck
state = strings.Title(l.ListContainer.State)
}
return state
diff --git a/cmd/podman/containers/run.go b/cmd/podman/containers/run.go
index 4ad8d3183..951981293 100644
--- a/cmd/podman/containers/run.go
+++ b/cmd/podman/containers/run.go
@@ -197,7 +197,7 @@ func run(cmd *cobra.Command, args []string) error {
s.Passwd = &runOpts.Passwd
runOpts.Spec = s
- if _, err := createPodIfNecessary(cmd, s, cliVals.Net); err != nil {
+ if err := createPodIfNecessary(cmd, s, cliVals.Net); err != nil {
return err
}
diff --git a/cmd/podman/machine/init.go b/cmd/podman/machine/init.go
index 06c1f7248..4991c6aa3 100644
--- a/cmd/podman/machine/init.go
+++ b/cmd/podman/machine/init.go
@@ -12,7 +12,6 @@ import (
"github.com/containers/podman/v4/pkg/machine"
"github.com/pkg/errors"
"github.com/spf13/cobra"
- "github.com/spf13/pflag"
)
var (
@@ -107,18 +106,8 @@ func init() {
flags.StringVar(&initOpts.IgnitionPath, IgnitionPathFlagName, "", "Path to ignition file")
_ = initCmd.RegisterFlagCompletionFunc(IgnitionPathFlagName, completion.AutocompleteDefault)
- 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)
+ rootfulFlagName := "rootful"
+ flags.BoolVar(&initOpts.Rootful, rootfulFlagName, false, "Whether this machine should prefer rootful container execution")
}
// TODO should we allow for a users to append to the qemu cmdline?
@@ -146,7 +135,6 @@ func initMachine(cmd *cobra.Command, args []string) error {
if err != nil {
return err
}
-
if finished, err := vm.Init(initOpts); err != nil || !finished {
// Finished = true, err = nil - Success! Log a message with further instructions
// Finished = false, err = nil - The installation is partially complete and podman should
@@ -155,7 +143,6 @@ func initMachine(cmd *cobra.Command, args []string) error {
// - a user has chosen to perform their own reboot
// - reexec for limited admin operations, returning to parent
// Finished = *, err != nil - Exit with an error message
-
return err
}
fmt.Println("Machine init complete")
diff --git a/cmd/podman/machine/set.go b/cmd/podman/machine/set.go
index b1dfb51da..4c15f1de1 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 --rootfull=false`,
+ Example: `podman machine set --rootful=false`,
ValidArgsFunction: completion.AutocompleteNone,
}
)
@@ -33,9 +33,8 @@ func init() {
})
flags := setCmd.Flags()
- rootfullFlagName := "rootfull"
- flags.BoolVar(&setOpts.Rootfull, rootfullFlagName, false, "Whether this machine should prefer rootfull container execution")
- flags.SetNormalizeFunc(aliasFlags)
+ rootfulFlagName := "rootful"
+ flags.BoolVar(&setOpts.Rootful, rootfulFlagName, false, "Whether this machine should prefer rootful container execution")
}
func setMachine(cmd *cobra.Command, args []string) error {
diff --git a/cmd/podman/root.go b/cmd/podman/root.go
index 500a475bd..9b1aa778b 100644
--- a/cmd/podman/root.go
+++ b/cmd/podman/root.go
@@ -429,6 +429,10 @@ func rootFlags(cmd *cobra.Command, opts *entities.PodmanConfig) {
pFlags.BoolVar(&opts.Trace, "trace", false, "Enable opentracing output (default false)")
+ volumePathFlagName := "volumepath"
+ pFlags.StringVar(&opts.Engine.VolumePath, volumePathFlagName, "", "Path to the volume directory in which volume data is stored")
+ _ = cmd.RegisterFlagCompletionFunc(volumePathFlagName, completion.AutocompleteDefault)
+
// Hide these flags for both ABI and Tunneling
for _, f := range []string{
"cpu-profile",
diff --git a/cmd/podman/system/connection/add.go b/cmd/podman/system/connection/add.go
index db575a689..387de3c58 100644
--- a/cmd/podman/system/connection/add.go
+++ b/cmd/podman/system/connection/add.go
@@ -112,7 +112,7 @@ func add(cmd *cobra.Command, args []string) error {
iden = cOpts.Identity
}
if uri.Path == "" || uri.Path == "/" {
- if uri.Path, err = getUDS(cmd, uri, iden); err != nil {
+ if uri.Path, err = getUDS(uri, iden); err != nil {
return err
}
}
@@ -204,7 +204,7 @@ func GetUserInfo(uri *url.URL) (*url.Userinfo, error) {
return url.User(usr.Username), nil
}
-func getUDS(cmd *cobra.Command, uri *url.URL, iden string) (string, error) {
+func getUDS(uri *url.URL, iden string) (string, error) {
cfg, err := ValidateAndConfigure(uri, iden)
if err != nil {
return "", errors.Wrapf(err, "failed to validate")