diff options
author | Daniel J Walsh <dwalsh@redhat.com> | 2018-08-27 11:22:28 -0400 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-08-28 14:29:12 +0000 |
commit | 1a90b2fd363bec5f9b57c1cd829ceb5890270f8c (patch) | |
tree | 7a043c8e78f02dc7ca5946a6670e1045c2e6c9f9 /cmd/podman | |
parent | 9e315518aa52c8cb80b2fae3bd48f6e52e6d0fc0 (diff) | |
download | podman-1a90b2fd363bec5f9b57c1cd829ceb5890270f8c.tar.gz podman-1a90b2fd363bec5f9b57c1cd829ceb5890270f8c.tar.bz2 podman-1a90b2fd363bec5f9b57c1cd829ceb5890270f8c.zip |
allow specification of entrypoint in the form of a slice
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Closes: #1352
Approved by: mheon
Diffstat (limited to 'cmd/podman')
-rw-r--r-- | cmd/podman/common.go | 2 | ||||
-rw-r--r-- | cmd/podman/create.go | 31 |
2 files changed, 22 insertions, 11 deletions
diff --git a/cmd/podman/common.go b/cmd/podman/common.go index 8ce3066c0..d9216850f 100644 --- a/cmd/podman/common.go +++ b/cmd/podman/common.go @@ -191,7 +191,7 @@ var createFlags = []cli.Flag{ Name: "dns-search", Usage: "Set custom DNS search domains", }, - cli.StringSliceFlag{ + cli.StringFlag{ Name: "entrypoint", Usage: "Overwrite the default ENTRYPOINT of the image", }, diff --git a/cmd/podman/create.go b/cmd/podman/create.go index 95b7a8bed..78b206543 100644 --- a/cmd/podman/create.go +++ b/cmd/podman/create.go @@ -316,6 +316,26 @@ func isPortInImagePorts(exposedPorts map[string]struct{}, port string) bool { return false } +func configureEntrypoint(c *cli.Context, data *inspect.ImageData) []string { + entrypoint := []string{} + if c.IsSet("entrypoint") { + // Force entrypoint to "" + if c.String("entrypoint") == "" { + return entrypoint + } + // Check if entrypoint specified is json + if err := json.Unmarshal([]byte(c.String("entrypoint")), &entrypoint); err == nil { + return entrypoint + } + // Return entrypoint as a single command + return []string{c.String("entrypoint")} + } + if data != nil { + return data.ContainerConfig.Entrypoint + } + return entrypoint +} + // Parses CLI options related to container creation into a config which can be // parsed into an OCI runtime spec func parseCreateOpts(ctx context.Context, c *cli.Context, runtime *libpod.Runtime, imageName string, data *inspect.ImageData) (*cc.CreateConfig, error) { @@ -555,16 +575,7 @@ func parseCreateOpts(ctx context.Context, c *cli.Context, runtime *libpod.Runtim workDir = data.ContainerConfig.WorkingDir } - // ENTRYPOINT - // User input entrypoint takes priority over image entrypoint - entrypoint := c.StringSlice("entrypoint") - if len(entrypoint) == 0 && data != nil { - entrypoint = data.ContainerConfig.Entrypoint - } - // if entrypoint=, we need to clear the entrypoint - if len(entrypoint) == 1 && c.IsSet("entrypoint") && strings.Join(c.StringSlice("entrypoint"), "") == "" { - entrypoint = []string{} - } + entrypoint := configureEntrypoint(c, data) // Build the command // If we have an entry point, it goes first if len(entrypoint) > 0 { |