diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-05-01 15:32:00 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-01 15:32:00 +0200 |
commit | 1230499e45554069f3e6ad073f7e1b0083787213 (patch) | |
tree | 1b135430cd6cde13b663d47f2ee4712dbc001d87 /pkg/specgen | |
parent | 2f3762eb911258016581187f072a24ac2724be3b (diff) | |
parent | aef7836b38570eb48bd0fd1c1c4ca37e9a9022f4 (diff) | |
download | podman-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 'pkg/specgen')
-rw-r--r-- | pkg/specgen/generate/container_create.go | 18 | ||||
-rw-r--r-- | pkg/specgen/generate/oci.go | 2 |
2 files changed, 8 insertions, 12 deletions
diff --git a/pkg/specgen/generate/container_create.go b/pkg/specgen/generate/container_create.go index 01ddcf9c8..14836035d 100644 --- a/pkg/specgen/generate/container_create.go +++ b/pkg/specgen/generate/container_create.go @@ -24,11 +24,10 @@ func MakeContainer(ctx context.Context, rt *libpod.Runtime, s *specgen.SpecGener // If joining a pod, retrieve the pod for use. var pod *libpod.Pod if s.Pod != "" { - foundPod, err := rt.LookupPod(s.Pod) + pod, err = rt.LookupPod(s.Pod) if err != nil { return nil, errors.Wrapf(err, "error retrieving pod %s", s.Pod) } - pod = foundPod } // Set defaults for unset namespaces @@ -130,12 +129,8 @@ func createContainerOptions(rt *libpod.Runtime, s *specgen.SpecGenerator, pod *l logrus.Debugf("setting container name %s", s.Name) options = append(options, libpod.WithName(s.Name)) } - if s.Pod != "" { - pod, err := rt.LookupPod(s.Pod) - if err != nil { - return nil, err - } - logrus.Debugf("adding container to pod %s", s.Pod) + if pod != nil { + logrus.Debugf("adding container to pod %s", pod.Name()) options = append(options, rt.WithPod(pod)) } destinations := []string{} @@ -160,11 +155,12 @@ func createContainerOptions(rt *libpod.Runtime, s *specgen.SpecGenerator, pod *l options = append(options, libpod.WithNamedVolumes(vols)) } - if len(s.Command) != 0 { + if s.Command != nil { options = append(options, libpod.WithCommand(s.Command)) } - - options = append(options, libpod.WithEntrypoint(s.Entrypoint)) + if s.Entrypoint != nil { + options = append(options, libpod.WithEntrypoint(s.Entrypoint)) + } if s.StopSignal != nil { options = append(options, libpod.WithStopSignal(*s.StopSignal)) } diff --git a/pkg/specgen/generate/oci.go b/pkg/specgen/generate/oci.go index 87262684e..f0b4d1111 100644 --- a/pkg/specgen/generate/oci.go +++ b/pkg/specgen/generate/oci.go @@ -67,7 +67,7 @@ func makeCommand(ctx context.Context, s *specgen.SpecGenerator, img *image.Image finalCommand = append(finalCommand, entrypoint...) command := s.Command - if len(command) == 0 && img != nil { + if command == nil && img != nil { newCmd, err := img.Cmd(ctx) if err != nil { return nil, err |