summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorStefan Becker <chemobejk@gmail.com>2019-07-13 18:22:41 +0300
committerStefan Becker <chemobejk@gmail.com>2019-07-14 10:33:01 +0300
commite4cba7d36a49353febfefcb25d2d820bc89e9d1b (patch)
treeda0d158215568fba288cd1db6a059c57c82c5fc9 /cmd
parentc59d08bc77855c0d0d946fa44850a0bf03b102c9 (diff)
downloadpodman-e4cba7d36a49353febfefcb25d2d820bc89e9d1b.tar.gz
podman-e4cba7d36a49353febfefcb25d2d820bc89e9d1b.tar.bz2
podman-e4cba7d36a49353febfefcb25d2d820bc89e9d1b.zip
create: improve parser for --healthcheck-command
Fix Docker CLI compatibility issue: the "--healthcheck-command" option value should not be split but instead be passed as single string to "CMD-SHELL", i.e. "/bin/sh -c <opt>". On the other hand implement the same extension as is already available for "--entrypoint", i.e. allow the option value to be a JSON array of strings. This will make life easier for tools like podman-compose. Updated "--healthcheck-command" option values in tests accordingly. Continuation of #3455 & #3507 Signed-off-by: Stefan Becker <chemobejk@gmail.com>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/podman/shared/create.go8
1 files changed, 5 insertions, 3 deletions
diff --git a/cmd/podman/shared/create.go b/cmd/podman/shared/create.go
index be1a731cc..17455c4c9 100644
--- a/cmd/podman/shared/create.go
+++ b/cmd/podman/shared/create.go
@@ -26,7 +26,6 @@ import (
"github.com/docker/docker/pkg/signal"
"github.com/docker/go-connections/nat"
"github.com/docker/go-units"
- "github.com/google/shlex"
"github.com/opencontainers/selinux/go-selinux/label"
"github.com/opentracing/opentracing-go"
"github.com/pkg/errors"
@@ -788,9 +787,12 @@ func makeHealthCheckFromCli(c *GenericCLIResults) (*manifest.Schema2HealthConfig
return nil, errors.New("Must define a healthcheck command for all healthchecks")
}
- cmd, err := shlex.Split(inCommand)
+ // first try to parse option value as JSON array of strings...
+ cmd := []string{}
+ err := json.Unmarshal([]byte(inCommand), &cmd)
if err != nil {
- return nil, errors.Wrap(err, "failed to parse healthcheck command")
+ // ...otherwise pass it to "/bin/sh -c" inside the container
+ cmd = []string{"CMD-SHELL", inCommand}
}
hc := manifest.Schema2HealthConfig{
Test: cmd,