diff options
author | baude <bbaude@redhat.com> | 2019-01-11 13:59:16 -0600 |
---|---|---|
committer | baude <bbaude@redhat.com> | 2019-01-11 14:01:57 -0600 |
commit | e10baba32673d4b6d9ada129941428fc8f8304eb (patch) | |
tree | 27c75727f7233e842b88d901903a316c18f11150 /pkg/spec | |
parent | 28c35cab8750f379a418e87ed6bd874a12ec158d (diff) | |
download | podman-e10baba32673d4b6d9ada129941428fc8f8304eb.tar.gz podman-e10baba32673d4b6d9ada129941428fc8f8304eb.tar.bz2 podman-e10baba32673d4b6d9ada129941428fc8f8304eb.zip |
podman play kube: add containers to pod
when defining containers, we missed the conditional logic to allow
the container to be defined with "WithPod" and so forth. I had to
slightly modify the createcontainer process to pass a libpod.Pod
that could override things; use nil as no pod.
Signed-off-by: baude <bbaude@redhat.com>
Diffstat (limited to 'pkg/spec')
-rw-r--r-- | pkg/spec/createconfig.go | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/pkg/spec/createconfig.go b/pkg/spec/createconfig.go index 87fce7e2e..632d60b55 100644 --- a/pkg/spec/createconfig.go +++ b/pkg/spec/createconfig.go @@ -341,10 +341,9 @@ func (c *CreateConfig) createExitCommand() []string { } // GetContainerCreateOptions takes a CreateConfig and returns a slice of CtrCreateOptions -func (c *CreateConfig) GetContainerCreateOptions(runtime *libpod.Runtime) ([]libpod.CtrCreateOption, error) { +func (c *CreateConfig) GetContainerCreateOptions(runtime *libpod.Runtime, pod *libpod.Pod) ([]libpod.CtrCreateOption, error) { var options []libpod.CtrCreateOption var portBindings []ocicni.PortMapping - var pod *libpod.Pod var err error if c.Interactive { @@ -358,12 +357,14 @@ func (c *CreateConfig) GetContainerCreateOptions(runtime *libpod.Runtime) ([]lib logrus.Debugf("appending name %s", c.Name) options = append(options, libpod.WithName(c.Name)) } - if c.Pod != "" { - logrus.Debugf("adding container to pod %s", c.Pod) - pod, err = runtime.LookupPod(c.Pod) - if err != nil { - return nil, errors.Wrapf(err, "unable to add container to pod %s", c.Pod) + if c.Pod != "" || pod != nil { + if pod == nil { + pod, err = runtime.LookupPod(c.Pod) + if err != nil { + return nil, errors.Wrapf(err, "unable to add container to pod %s", c.Pod) + } } + logrus.Debugf("adding container to pod %s", c.Pod) options = append(options, runtime.WithPod(pod)) } if len(c.PortBindings) > 0 { |