diff options
author | Daniel J Walsh <dwalsh@redhat.com> | 2020-12-23 04:16:08 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-23 04:16:08 -0500 |
commit | 9b6324f51f7279683f2d2a6c90542029e1ded1ee (patch) | |
tree | 08ab5669933d7ac4ca4c696c23a64f65afc2ea48 /pkg/specgen/generate/kube/kube.go | |
parent | 07663f74c48d11732a3330248f837d5abf86fe9c (diff) | |
parent | 1c437f039ad438562d9cf0cfc6b52896c3669635 (diff) | |
download | podman-9b6324f51f7279683f2d2a6c90542029e1ded1ee.tar.gz podman-9b6324f51f7279683f2d2a6c90542029e1ded1ee.tar.bz2 podman-9b6324f51f7279683f2d2a6c90542029e1ded1ee.zip |
Merge pull request #8807 from haircommander/fix-play-kube
play kube: fix args/command handling
Diffstat (limited to 'pkg/specgen/generate/kube/kube.go')
-rw-r--r-- | pkg/specgen/generate/kube/kube.go | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/pkg/specgen/generate/kube/kube.go b/pkg/specgen/generate/kube/kube.go index 5cc7891ac..c64fe76a6 100644 --- a/pkg/specgen/generate/kube/kube.go +++ b/pkg/specgen/generate/kube/kube.go @@ -112,11 +112,18 @@ func ToSpecGen(ctx context.Context, containerYAML v1.Container, iid string, newI return nil, err } s.WorkDir = "/" + // We will use "Docker field name" internally here to avoid confusion + // and reference the "Kubernetes field name" when referencing the YAML + // ref: https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#notes + entrypoint := []string{} + cmd := []string{} if imageData != nil && imageData.Config != nil { if imageData.Config.WorkingDir != "" { s.WorkDir = imageData.Config.WorkingDir } - s.Command = imageData.Config.Entrypoint + // Pull entrypoint and cmd from image + entrypoint = imageData.Config.Entrypoint + cmd = imageData.Config.Cmd s.Labels = imageData.Config.Labels if len(imageData.Config.StopSignal) > 0 { stopSignal, err := util.ParseSignal(imageData.Config.StopSignal) @@ -126,13 +133,18 @@ func ToSpecGen(ctx context.Context, containerYAML v1.Container, iid string, newI s.StopSignal = &stopSignal } } + // If only the yaml.Command is specified, set it as the entrypoint and drop the image Cmd if len(containerYAML.Command) != 0 { - s.Command = containerYAML.Command + entrypoint = containerYAML.Command + cmd = []string{} } - // doc https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#notes + // Only override the cmd field if yaml.Args is specified + // Keep the image entrypoint, or the yaml.command if specified if len(containerYAML.Args) != 0 { - s.Command = append(s.Command, containerYAML.Args...) + cmd = containerYAML.Args } + + s.Command = append(entrypoint, cmd...) // FIXME, // we are currently ignoring imageData.Config.ExposedPorts if containerYAML.WorkingDir != "" { |