summaryrefslogtreecommitdiff
path: root/pkg/bindings/pods
diff options
context:
space:
mode:
authorBrent Baude <bbaude@redhat.com>2020-03-24 07:28:36 -0500
committerBrent Baude <bbaude@redhat.com>2020-03-27 09:04:10 -0500
commite56d5295614b745115abf0198f7b67ae157aae1e (patch)
tree4b18581f6656f2bd6455e797f69ab7d45535ec6a /pkg/bindings/pods
parent7007680bfdee8c36b855a97ee45d268b24bde7d3 (diff)
downloadpodman-e56d5295614b745115abf0198f7b67ae157aae1e.tar.gz
podman-e56d5295614b745115abf0198f7b67ae157aae1e.tar.bz2
podman-e56d5295614b745115abf0198f7b67ae157aae1e.zip
podmanv2 pod create using podspecgen
using the factory approach similar to container, we now create pods based on a pod spec generator. wired up the podmanv2 pod create command, podcreatewithspec binding, simple binding test, and apiv2 endpoint. also included some code refactoring as it introduced as easy circular import. Signed-off-by: Brent Baude <bbaude@redhat.com>
Diffstat (limited to 'pkg/bindings/pods')
-rw-r--r--pkg/bindings/pods/pods.go24
1 files changed, 21 insertions, 3 deletions
diff --git a/pkg/bindings/pods/pods.go b/pkg/bindings/pods/pods.go
index 49cce6e2b..bb0abebc4 100644
--- a/pkg/bindings/pods/pods.go
+++ b/pkg/bindings/pods/pods.go
@@ -5,15 +5,33 @@ import (
"net/http"
"net/url"
"strconv"
+ "strings"
"github.com/containers/libpod/libpod"
"github.com/containers/libpod/pkg/bindings"
"github.com/containers/libpod/pkg/domain/entities"
+ "github.com/containers/libpod/pkg/specgen"
+ jsoniter "github.com/json-iterator/go"
)
-func CreatePod() error {
- // TODO
- return bindings.ErrNotImplemented
+func CreatePodFromSpec(ctx context.Context, s *specgen.PodSpecGenerator) (*entities.PodCreateReport, error) {
+ var (
+ pcr entities.PodCreateReport
+ )
+ conn, err := bindings.GetClient(ctx)
+ if err != nil {
+ return nil, err
+ }
+ specgenString, err := jsoniter.MarshalToString(s)
+ if err != nil {
+ return nil, err
+ }
+ stringReader := strings.NewReader(specgenString)
+ response, err := conn.DoRequest(stringReader, http.MethodPost, "/pods/create", nil)
+ if err != nil {
+ return nil, err
+ }
+ return &pcr, response.Process(&pcr)
}
// Exists is a lightweight method to determine if a pod exists in local storage