summaryrefslogtreecommitdiff
path: root/pkg/specgen/create.go
diff options
context:
space:
mode:
authorBrent Baude <bbaude@redhat.com>2020-02-26 15:15:36 -0600
committerBrent Baude <bbaude@redhat.com>2020-03-06 14:31:45 -0600
commit8b5e2a6297e6f6a5426551d1648278906a9d23de (patch)
tree7de8fe4102b581404dc3c012445750008a5b5495 /pkg/specgen/create.go
parenta61d05f667f6ba74ed060d5938e99d9838c1763f (diff)
downloadpodman-8b5e2a6297e6f6a5426551d1648278906a9d23de.tar.gz
podman-8b5e2a6297e6f6a5426551d1648278906a9d23de.tar.bz2
podman-8b5e2a6297e6f6a5426551d1648278906a9d23de.zip
add default network for apiv2 create
during container creation, if no network is provided, we need to add a default value so the container can be later started. use apiv2 container creation for RunTopContainer instead of an exec to the system podman. RunTopContainer now also returns the container id and an error. added a libpod commit endpoint. also, changed the use of the connections and bindings slightly to make it more convenient to write tests. Fixes: 5366 Signed-off-by: Brent Baude <bbaude@redhat.com>
Diffstat (limited to 'pkg/specgen/create.go')
-rw-r--r--pkg/specgen/create.go10
1 files changed, 6 insertions, 4 deletions
diff --git a/pkg/specgen/create.go b/pkg/specgen/create.go
index e6ac53016..99a99083b 100644
--- a/pkg/specgen/create.go
+++ b/pkg/specgen/create.go
@@ -13,7 +13,6 @@ import (
// MakeContainer creates a container based on the SpecGenerator
func (s *SpecGenerator) MakeContainer(rt *libpod.Runtime) (*libpod.Container, error) {
- var pod *libpod.Pod
if err := s.validate(rt); err != nil {
return nil, errors.Wrap(err, "invalid config provided")
}
@@ -22,7 +21,7 @@ func (s *SpecGenerator) MakeContainer(rt *libpod.Runtime) (*libpod.Container, er
return nil, err
}
- options, err := s.createContainerOptions(rt, pod)
+ options, err := s.createContainerOptions(rt)
if err != nil {
return nil, err
}
@@ -46,7 +45,7 @@ func (s *SpecGenerator) MakeContainer(rt *libpod.Runtime) (*libpod.Container, er
return rt.NewContainer(context.Background(), runtimeSpec, options...)
}
-func (s *SpecGenerator) createContainerOptions(rt *libpod.Runtime, pod *libpod.Pod) ([]libpod.CtrCreateOption, error) {
+func (s *SpecGenerator) createContainerOptions(rt *libpod.Runtime) ([]libpod.CtrCreateOption, error) {
var options []libpod.CtrCreateOption
var err error
@@ -61,6 +60,10 @@ func (s *SpecGenerator) createContainerOptions(rt *libpod.Runtime, pod *libpod.P
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)
options = append(options, rt.WithPod(pod))
}
@@ -116,7 +119,6 @@ func (s *SpecGenerator) createContainerOptions(rt *libpod.Runtime, pod *libpod.P
}
options = append(options, namespaceOptions...)
- // TODO NetworkNS still needs to be done!
if len(s.ConmonPidFile) > 0 {
options = append(options, libpod.WithConmonPidFile(s.ConmonPidFile))
}