summaryrefslogtreecommitdiff
path: root/cmd/podman
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-09-16 15:05:28 -0400
committerGitHub <noreply@github.com>2021-09-16 15:05:28 -0400
commit2a30b60666001b7039aaf5318ffeaa0374433f27 (patch)
tree421afa18f2bdb6c03d2be3872b6135efdf8282da /cmd/podman
parentfcb22e82b518bd8de31bc152b78d2cbc6ab09964 (diff)
parent29edeaa892df2f533f997adb0736f09a6f8e0965 (diff)
downloadpodman-2a30b60666001b7039aaf5318ffeaa0374433f27.tar.gz
podman-2a30b60666001b7039aaf5318ffeaa0374433f27.tar.bz2
podman-2a30b60666001b7039aaf5318ffeaa0374433f27.zip
Merge pull request #11598 from mheon/34_backportsreleasenotes
Backports and release notes for v3.4.0-RC1
Diffstat (limited to 'cmd/podman')
-rw-r--r--cmd/podman/common/create.go32
-rw-r--r--cmd/podman/images/build.go12
-rw-r--r--cmd/podman/machine/ssh.go37
-rw-r--r--cmd/podman/registry/registry.go4
-rw-r--r--cmd/podman/root.go10
-rw-r--r--cmd/podman/system/migrate.go5
-rw-r--r--cmd/podman/system/renumber.go5
-rw-r--r--cmd/podman/system/reset.go5
8 files changed, 75 insertions, 35 deletions
diff --git a/cmd/podman/common/create.go b/cmd/podman/common/create.go
index 325c1dc69..f3bf2c0a2 100644
--- a/cmd/podman/common/create.go
+++ b/cmd/podman/common/create.go
@@ -90,6 +90,22 @@ func DefineCreateFlags(cmd *cobra.Command, cf *entities.ContainerCreateOptions,
)
_ = cmd.RegisterFlagCompletionFunc(cgroupsFlagName, AutocompleteCgroupMode)
+ cpusFlagName := "cpus"
+ createFlags.Float64Var(
+ &cf.CPUS,
+ cpusFlagName, 0,
+ "Number of CPUs. The default is 0.000 which means no limit",
+ )
+ _ = cmd.RegisterFlagCompletionFunc(cpusFlagName, completion.AutocompleteNone)
+
+ cpusetCpusFlagName := "cpuset-cpus"
+ createFlags.StringVar(
+ &cf.CPUSetCPUs,
+ cpusetCpusFlagName, "",
+ "CPUs in which to allow execution (0-3, 0,1)",
+ )
+ _ = cmd.RegisterFlagCompletionFunc(cpusetCpusFlagName, completion.AutocompleteNone)
+
cpuPeriodFlagName := "cpu-period"
createFlags.Uint64Var(
&cf.CPUPeriod,
@@ -784,22 +800,6 @@ func DefineCreateFlags(cmd *cobra.Command, cf *entities.ContainerCreateOptions,
)
_ = cmd.RegisterFlagCompletionFunc(conmonPidfileFlagName, completion.AutocompleteDefault)
- cpusFlagName := "cpus"
- createFlags.Float64Var(
- &cf.CPUS,
- cpusFlagName, 0,
- "Number of CPUs. The default is 0.000 which means no limit",
- )
- _ = cmd.RegisterFlagCompletionFunc(cpusFlagName, completion.AutocompleteNone)
-
- cpusetCpusFlagName := "cpuset-cpus"
- createFlags.StringVar(
- &cf.CPUSetCPUs,
- cpusetCpusFlagName, "",
- "CPUs in which to allow execution (0-3, 0,1)",
- )
- _ = cmd.RegisterFlagCompletionFunc(cpusetCpusFlagName, completion.AutocompleteNone)
-
entrypointFlagName := ""
if !isInfra {
entrypointFlagName = "entrypoint"
diff --git a/cmd/podman/images/build.go b/cmd/podman/images/build.go
index a1a28b809..642da0c83 100644
--- a/cmd/podman/images/build.go
+++ b/cmd/podman/images/build.go
@@ -11,6 +11,7 @@ import (
buildahDefine "github.com/containers/buildah/define"
buildahCLI "github.com/containers/buildah/pkg/cli"
"github.com/containers/buildah/pkg/parse"
+ buildahUtil "github.com/containers/buildah/pkg/util"
"github.com/containers/common/pkg/auth"
"github.com/containers/common/pkg/completion"
"github.com/containers/common/pkg/config"
@@ -359,6 +360,12 @@ func buildFlagsWrapperToOptions(c *cobra.Command, contextDir string, flags *buil
}
}
+ cleanTmpFile := false
+ flags.Authfile, cleanTmpFile = buildahUtil.MirrorToTempFileIfPathIsDescriptor(flags.Authfile)
+ if cleanTmpFile {
+ defer os.Remove(flags.Authfile)
+ }
+
args := make(map[string]string)
if c.Flag("build-arg").Changed {
for _, arg := range flags.BuildArg {
@@ -476,7 +483,7 @@ func buildFlagsWrapperToOptions(c *cobra.Command, contextDir string, flags *buil
runtimeFlags = append(runtimeFlags, "--systemd-cgroup")
}
- imageOS, arch, err := parse.PlatformFromOptions(c)
+ platforms, err := parse.PlatformsFromOptions(c)
if err != nil {
return nil, err
}
@@ -490,7 +497,6 @@ func buildFlagsWrapperToOptions(c *cobra.Command, contextDir string, flags *buil
AddCapabilities: flags.CapAdd,
AdditionalTags: tags,
Annotations: flags.Annotation,
- Architecture: arch,
Args: args,
BlobDirectory: flags.BlobCache,
CNIConfigDir: flags.CNIConfigDir,
@@ -516,11 +522,11 @@ func buildFlagsWrapperToOptions(c *cobra.Command, contextDir string, flags *buil
MaxPullPushRetries: 3,
NamespaceOptions: nsValues,
NoCache: flags.NoCache,
- OS: imageOS,
OciDecryptConfig: decConfig,
Out: stdout,
Output: output,
OutputFormat: format,
+ Platforms: platforms,
PullPolicy: pullPolicy,
PullPushRetryDelay: 2 * time.Second,
Quiet: flags.Quiet,
diff --git a/cmd/podman/machine/ssh.go b/cmd/podman/machine/ssh.go
index 85101a641..84e9e88ab 100644
--- a/cmd/podman/machine/ssh.go
+++ b/cmd/podman/machine/ssh.go
@@ -3,6 +3,9 @@
package machine
import (
+ "net/url"
+
+ "github.com/containers/common/pkg/config"
"github.com/containers/podman/v3/cmd/podman/registry"
"github.com/containers/podman/v3/pkg/machine"
"github.com/containers/podman/v3/pkg/machine/qemu"
@@ -44,6 +47,14 @@ func ssh(cmd *cobra.Command, args []string) error {
// Set the VM to default
vmName := defaultMachineName
+
+ // If we're not given a VM name, use the remote username from the connection config
+ if len(args) == 0 {
+ sshOpts.Username, err = remoteConnectionUsername()
+ if err != nil {
+ return err
+ }
+ }
// If len is greater than 0, it means we may have been
// provided the VM name. If so, we check. The VM name,
// if provided, must be in args[0].
@@ -57,16 +68,25 @@ func ssh(cmd *cobra.Command, args []string) error {
if validVM {
vmName = args[0]
} else {
+ sshOpts.Username, err = remoteConnectionUsername()
+ if err != nil {
+ return err
+ }
sshOpts.Args = append(sshOpts.Args, args[0])
}
}
}
+
// If len is greater than 1, it means we might have been
// given a vmname and args or just args
if len(args) > 1 {
if validVM {
sshOpts.Args = args[1:]
} else {
+ sshOpts.Username, err = remoteConnectionUsername()
+ if err != nil {
+ return err
+ }
sshOpts.Args = args
}
}
@@ -80,3 +100,20 @@ func ssh(cmd *cobra.Command, args []string) error {
}
return vm.SSH(vmName, sshOpts)
}
+
+func remoteConnectionUsername() (string, error) {
+ cfg, err := config.ReadCustomConfig()
+ if err != nil {
+ return "", err
+ }
+ dest, _, err := cfg.ActiveDestination()
+ if err != nil {
+ return "", err
+ }
+ uri, err := url.Parse(dest)
+ if err != nil {
+ return "", err
+ }
+ username := uri.User.String()
+ return username, nil
+}
diff --git a/cmd/podman/registry/registry.go b/cmd/podman/registry/registry.go
index 607ef6d8e..e1ab14297 100644
--- a/cmd/podman/registry/registry.go
+++ b/cmd/podman/registry/registry.go
@@ -23,12 +23,10 @@ type CliCommand struct {
Parent *cobra.Command
}
-const ExecErrorCodeGeneric = 125
-
var (
cliCtx context.Context
containerEngine entities.ContainerEngine
- exitCode = ExecErrorCodeGeneric
+ exitCode = 0
imageEngine entities.ImageEngine
// Commands holds the cobra.Commands to present to the user, including
diff --git a/cmd/podman/root.go b/cmd/podman/root.go
index 371ded9a8..c798e6634 100644
--- a/cmd/podman/root.go
+++ b/cmd/podman/root.go
@@ -89,14 +89,10 @@ func init() {
func Execute() {
if err := rootCmd.ExecuteContext(registry.GetContextWithOptions()); err != nil {
+ if registry.GetExitCode() == 0 {
+ registry.SetExitCode(define.ExecErrorCodeGeneric)
+ }
fmt.Fprintln(os.Stderr, formatError(err))
- } else if registry.GetExitCode() == registry.ExecErrorCodeGeneric {
- // The exitCode modified from registry.ExecErrorCodeGeneric,
- // indicates an application
- // running inside of a container failed, as opposed to the
- // podman command failed. Must exit with that exit code
- // otherwise command exited correctly.
- registry.SetExitCode(0)
}
os.Exit(registry.GetExitCode())
}
diff --git a/cmd/podman/system/migrate.go b/cmd/podman/system/migrate.go
index b9dc272d7..d78ac7286 100644
--- a/cmd/podman/system/migrate.go
+++ b/cmd/podman/system/migrate.go
@@ -9,6 +9,7 @@ import (
"github.com/containers/common/pkg/completion"
"github.com/containers/podman/v3/cmd/podman/registry"
"github.com/containers/podman/v3/cmd/podman/validate"
+ "github.com/containers/podman/v3/libpod/define"
"github.com/containers/podman/v3/pkg/domain/entities"
"github.com/containers/podman/v3/pkg/domain/infra"
"github.com/spf13/cobra"
@@ -60,14 +61,14 @@ func migrate(cmd *cobra.Command, args []string) {
engine, err := infra.NewSystemEngine(entities.MigrateMode, registry.PodmanConfig())
if err != nil {
fmt.Println(err)
- os.Exit(125)
+ os.Exit(define.ExecErrorCodeGeneric)
}
defer engine.Shutdown(registry.Context())
err = engine.Migrate(registry.Context(), cmd.Flags(), registry.PodmanConfig(), migrateOptions)
if err != nil {
fmt.Println(err)
- os.Exit(125)
+ os.Exit(define.ExecErrorCodeGeneric)
}
os.Exit(0)
}
diff --git a/cmd/podman/system/renumber.go b/cmd/podman/system/renumber.go
index 83a873c2a..f27abf570 100644
--- a/cmd/podman/system/renumber.go
+++ b/cmd/podman/system/renumber.go
@@ -9,6 +9,7 @@ import (
"github.com/containers/common/pkg/completion"
"github.com/containers/podman/v3/cmd/podman/registry"
"github.com/containers/podman/v3/cmd/podman/validate"
+ "github.com/containers/podman/v3/libpod/define"
"github.com/containers/podman/v3/pkg/domain/entities"
"github.com/containers/podman/v3/pkg/domain/infra"
"github.com/spf13/cobra"
@@ -47,14 +48,14 @@ func renumber(cmd *cobra.Command, args []string) {
engine, err := infra.NewSystemEngine(entities.RenumberMode, registry.PodmanConfig())
if err != nil {
fmt.Println(err)
- os.Exit(125)
+ os.Exit(define.ExecErrorCodeGeneric)
}
defer engine.Shutdown(registry.Context())
err = engine.Renumber(registry.Context(), cmd.Flags(), registry.PodmanConfig())
if err != nil {
fmt.Println(err)
- os.Exit(125)
+ os.Exit(define.ExecErrorCodeGeneric)
}
os.Exit(0)
}
diff --git a/cmd/podman/system/reset.go b/cmd/podman/system/reset.go
index c64d09ed2..8a05bb09f 100644
--- a/cmd/podman/system/reset.go
+++ b/cmd/podman/system/reset.go
@@ -11,6 +11,7 @@ import (
"github.com/containers/common/pkg/completion"
"github.com/containers/podman/v3/cmd/podman/registry"
"github.com/containers/podman/v3/cmd/podman/validate"
+ "github.com/containers/podman/v3/libpod/define"
"github.com/containers/podman/v3/pkg/domain/entities"
"github.com/containers/podman/v3/pkg/domain/infra"
"github.com/sirupsen/logrus"
@@ -87,13 +88,13 @@ WARNING! This will remove:
engine, err := infra.NewSystemEngine(entities.ResetMode, registry.PodmanConfig())
if err != nil {
logrus.Error(err)
- os.Exit(125)
+ os.Exit(define.ExecErrorCodeGeneric)
}
defer engine.Shutdown(registry.Context())
if err := engine.Reset(registry.Context()); err != nil {
logrus.Error(err)
- os.Exit(125)
+ os.Exit(define.ExecErrorCodeGeneric)
}
os.Exit(0)
}