summaryrefslogtreecommitdiff
path: root/cmd/podman/common/specgen.go
diff options
context:
space:
mode:
authorcdoern <cbdoer23@g.holycross.edu>2021-07-26 09:05:05 -0400
committercdoern <cdoern@redhat.com>2021-07-26 16:58:38 -0400
commitfd1f57b3a667f69bb2ae424ec7a7735ef8f1fda4 (patch)
treed403ecdec13e912e980b01133f0ae995ce55f4cf /cmd/podman/common/specgen.go
parentbef1f03d3ca8bfd90f4cbb295d99bf97df74a815 (diff)
downloadpodman-fd1f57b3a667f69bb2ae424ec7a7735ef8f1fda4.tar.gz
podman-fd1f57b3a667f69bb2ae424ec7a7735ef8f1fda4.tar.bz2
podman-fd1f57b3a667f69bb2ae424ec7a7735ef8f1fda4.zip
Fixed Healthcheck formatting, string to []string
Compat healthcheck tests are of the format []string but podman's were of the format string. Converted podman's to []string at the specgen level since it has the same effect and removed the incorrect parsing of compat healthchecks. fixes #10617 Signed-off-by: cdoern <cdoern@redhat.com>
Diffstat (limited to 'cmd/podman/common/specgen.go')
-rw-r--r--cmd/podman/common/specgen.go31
1 files changed, 17 insertions, 14 deletions
diff --git a/cmd/podman/common/specgen.go b/cmd/podman/common/specgen.go
index 2f45e559d..c0cc7d17b 100644
--- a/cmd/podman/common/specgen.go
+++ b/cmd/podman/common/specgen.go
@@ -655,26 +655,29 @@ func FillOutSpecGen(s *specgen.SpecGenerator, c *ContainerCLIOpts, args []string
return nil
}
-func makeHealthCheckFromCli(inCmd, interval string, retries uint, timeout, startPeriod string) (*manifest.Schema2HealthConfig, error) {
+func makeHealthCheckFromCli(inCmd string, interval string, retries uint, timeout, startPeriod string) (*manifest.Schema2HealthConfig, error) {
+ var cmdArr []string
+ cmdSplitPrelim := strings.SplitN(inCmd, " ", 2)
+ if cmdSplitPrelim[0] == "CMD-SHELL" {
+ cmdArr = cmdSplitPrelim
+ } else if cmdSplitPrelim[0] != "CMD" && cmdSplitPrelim[0] != "none" { // if it isnt a cmd-shell or a cmd, it is a command
+ cmdArr = []string{"CMD-SHELL"}
+ cmdArr = append(cmdArr, inCmd)
+ } else {
+ cmdArr = strings.Fields(inCmd)
+ }
// Every healthcheck requires a command
- if len(inCmd) == 0 {
+ if len(cmdArr) == 0 {
return nil, errors.New("Must define a healthcheck command for all healthchecks")
}
- // first try to parse option value as JSON array of strings...
- cmd := []string{}
-
- if inCmd == "none" {
- cmd = []string{"NONE"}
- } else {
- err := json.Unmarshal([]byte(inCmd), &cmd)
- if err != nil {
- // ...otherwise pass it to "/bin/sh -c" inside the container
- cmd = []string{"CMD-SHELL", inCmd}
- }
+ if cmdArr[0] == "none" { // if specified to remove healtcheck
+ cmdArr = []string{"NONE"}
}
+
+ // healthcheck is by default an array, so we simply pass the user input
hc := manifest.Schema2HealthConfig{
- Test: cmd,
+ Test: cmdArr,
}
if interval == "disable" {