summaryrefslogtreecommitdiff
path: root/cmd/podman/common
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-05-01 15:32:00 +0200
committerGitHub <noreply@github.com>2020-05-01 15:32:00 +0200
commit1230499e45554069f3e6ad073f7e1b0083787213 (patch)
tree1b135430cd6cde13b663d47f2ee4712dbc001d87 /cmd/podman/common
parent2f3762eb911258016581187f072a24ac2724be3b (diff)
parentaef7836b38570eb48bd0fd1c1c4ca37e9a9022f4 (diff)
downloadpodman-1230499e45554069f3e6ad073f7e1b0083787213.tar.gz
podman-1230499e45554069f3e6ad073f7e1b0083787213.tar.bz2
podman-1230499e45554069f3e6ad073f7e1b0083787213.zip
Merge pull request #6016 from giuseppe/fix-create
v2, podman: fix create and entrypoint tests
Diffstat (limited to 'cmd/podman/common')
-rw-r--r--cmd/podman/common/create.go28
-rw-r--r--cmd/podman/common/create_opts.go2
-rw-r--r--cmd/podman/common/specgen.go23
3 files changed, 21 insertions, 32 deletions
diff --git a/cmd/podman/common/create.go b/cmd/podman/common/create.go
index a0aed984c..0f9476754 100644
--- a/cmd/podman/common/create.go
+++ b/cmd/podman/common/create.go
@@ -49,9 +49,7 @@ func GetCreateFlags(cf *ContainerCLIOpts) *pflag.FlagSet {
"cap-drop", []string{},
"Drop capabilities from the container",
)
- cgroupNS := ""
- createFlags.StringVar(
- &cgroupNS,
+ createFlags.String(
"cgroupns", containerConfig.CgroupNS(),
"cgroup namespace to use",
)
@@ -155,9 +153,7 @@ func GetCreateFlags(cf *ContainerCLIOpts) *pflag.FlagSet {
"device-write-iops", []string{},
"Limit write rate (IO per second) to a device (e.g. --device-write-iops=/dev/sda:1000)",
)
- createFlags.StringVar(
- &cf.Entrypoint,
- "entrypoint", "",
+ createFlags.String("entrypoint", "",
"Overwrite the default ENTRYPOINT of the image",
)
createFlags.StringArrayVarP(
@@ -248,9 +244,7 @@ func GetCreateFlags(cf *ContainerCLIOpts) *pflag.FlagSet {
"interactive", "i", false,
"Keep STDIN open even if not attached",
)
- ipcNS := ""
- createFlags.StringVar(
- &ipcNS,
+ createFlags.String(
"ipc", containerConfig.IPCNS(),
"IPC namespace to use",
)
@@ -331,9 +325,7 @@ func GetCreateFlags(cf *ContainerCLIOpts) *pflag.FlagSet {
"use `OS` instead of the running OS for choosing images",
)
// markFlagHidden(createFlags, "override-os")
- pid := ""
- createFlags.StringVar(
- &pid,
+ createFlags.String(
"pid", containerConfig.PidNS(),
"PID namespace to use",
)
@@ -397,9 +389,7 @@ func GetCreateFlags(cf *ContainerCLIOpts) *pflag.FlagSet {
"security-opt", containerConfig.SecurityOptions(),
"Security Options",
)
- shmSize := ""
- createFlags.StringVar(
- &shmSize,
+ createFlags.String(
"shm-size", containerConfig.ShmSize(),
"Size of /dev/shm "+sizeWithUnitFormat,
)
@@ -464,15 +454,11 @@ func GetCreateFlags(cf *ContainerCLIOpts) *pflag.FlagSet {
"user", "u", "",
"Username or UID (format: <name|uid>[:<group|gid>])",
)
- userNS := ""
- createFlags.StringVar(
- &userNS,
+ createFlags.String(
"userns", containerConfig.Containers.UserNS,
"User namespace to use",
)
- utsNS := ""
- createFlags.StringVar(
- &utsNS,
+ createFlags.String(
"uts", containerConfig.Containers.UTSNS,
"UTS namespace to use",
)
diff --git a/cmd/podman/common/create_opts.go b/cmd/podman/common/create_opts.go
index 2f08bb6a6..c275b1674 100644
--- a/cmd/podman/common/create_opts.go
+++ b/cmd/podman/common/create_opts.go
@@ -31,7 +31,7 @@ type ContainerCLIOpts struct {
DeviceReadIOPs []string
DeviceWriteBPs []string
DeviceWriteIOPs []string
- Entrypoint string
+ Entrypoint *string
env []string
EnvHost bool
EnvFile []string
diff --git a/cmd/podman/common/specgen.go b/cmd/podman/common/specgen.go
index 96cd630a3..7250f88bb 100644
--- a/cmd/podman/common/specgen.go
+++ b/cmd/podman/common/specgen.go
@@ -364,20 +364,20 @@ func FillOutSpecGen(s *specgen.SpecGenerator, c *ContainerCLIOpts, args []string
s.WorkDir = workDir
entrypoint := []string{}
userCommand := []string{}
- if ep := c.Entrypoint; len(ep) > 0 {
- // Check if entrypoint specified is json
- if err := json.Unmarshal([]byte(c.Entrypoint), &entrypoint); err != nil {
- entrypoint = append(entrypoint, ep)
+ if c.Entrypoint != nil {
+ if ep := *c.Entrypoint; len(ep) > 0 {
+ // Check if entrypoint specified is json
+ if err := json.Unmarshal([]byte(*c.Entrypoint), &entrypoint); err != nil {
+ entrypoint = append(entrypoint, ep)
+ }
}
+ s.Entrypoint = entrypoint
}
-
var command []string
- s.Entrypoint = entrypoint
-
// Build the command
// If we have an entry point, it goes first
- if len(entrypoint) > 0 {
+ if c.Entrypoint != nil {
command = entrypoint
}
if len(inputCommand) > 0 {
@@ -386,9 +386,12 @@ func FillOutSpecGen(s *specgen.SpecGenerator, c *ContainerCLIOpts, args []string
userCommand = append(userCommand, inputCommand...)
}
- if len(inputCommand) > 0 {
+ switch {
+ case len(inputCommand) > 0:
s.Command = userCommand
- } else {
+ case c.Entrypoint != nil:
+ s.Command = []string{}
+ default:
s.Command = command
}