summaryrefslogtreecommitdiff
path: root/pkg/api/handlers/libpod
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-09-15 16:11:14 -0400
committerGitHub <noreply@github.com>2021-09-15 16:11:14 -0400
commit5f41ffdd194a828625b3bb6ec55ed87d2830fe58 (patch)
treea625a713dc2205ac80122883f3532fc31bfb8fe2 /pkg/api/handlers/libpod
parent505c9718cc717433780be8240250a247253ba34f (diff)
parent5e8309464aea005fbc1604c304a94760aff4ee9a (diff)
downloadpodman-5f41ffdd194a828625b3bb6ec55ed87d2830fe58.tar.gz
podman-5f41ffdd194a828625b3bb6ec55ed87d2830fe58.tar.bz2
podman-5f41ffdd194a828625b3bb6ec55ed87d2830fe58.zip
Merge pull request #11322 from Luap99/network-libpod
Wire network interface into libpod
Diffstat (limited to 'pkg/api/handlers/libpod')
-rw-r--r--pkg/api/handlers/libpod/networks.go25
-rw-r--r--pkg/api/handlers/libpod/swagger.go14
2 files changed, 16 insertions, 23 deletions
diff --git a/pkg/api/handlers/libpod/networks.go b/pkg/api/handlers/libpod/networks.go
index 122ab1d3d..fcd8e0231 100644
--- a/pkg/api/handlers/libpod/networks.go
+++ b/pkg/api/handlers/libpod/networks.go
@@ -6,7 +6,7 @@ import (
"github.com/containers/podman/v3/libpod"
"github.com/containers/podman/v3/libpod/define"
- "github.com/containers/podman/v3/libpod/network"
+ "github.com/containers/podman/v3/libpod/network/types"
"github.com/containers/podman/v3/pkg/api/handlers/utils"
api "github.com/containers/podman/v3/pkg/api/types"
"github.com/containers/podman/v3/pkg/domain/entities"
@@ -18,27 +18,14 @@ import (
func CreateNetwork(w http.ResponseWriter, r *http.Request) {
runtime := r.Context().Value(api.RuntimeKey).(*libpod.Runtime)
- decoder := r.Context().Value(api.DecoderKey).(*schema.Decoder)
- options := entities.NetworkCreateOptions{}
- if err := json.NewDecoder(r.Body).Decode(&options); err != nil {
- utils.Error(w, "unable to marshall input", http.StatusInternalServerError, errors.Wrap(err, "Decode()"))
+ network := types.Network{}
+ if err := json.NewDecoder(r.Body).Decode(&network); err != nil {
+ utils.Error(w, "unable to marshall input", http.StatusInternalServerError, errors.Wrap(err, "decode body"))
return
}
- query := struct {
- Name string `schema:"name"`
- }{
- // override any golang type defaults
- }
- if err := decoder.Decode(&query, r.URL.Query()); err != nil {
- utils.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest,
- errors.Wrapf(err, "failed to parse parameters for %s", r.URL.String()))
- return
- }
- if len(options.Driver) < 1 {
- options.Driver = network.DefaultNetworkDriver
- }
+
ic := abi.ContainerEngine{Libpod: runtime}
- report, err := ic.NetworkCreate(r.Context(), query.Name, options)
+ report, err := ic.Libpod.Network().NetworkCreate(network)
if err != nil {
utils.InternalServerError(w, err)
return
diff --git a/pkg/api/handlers/libpod/swagger.go b/pkg/api/handlers/libpod/swagger.go
index 6116a7274..7ccfdd0f3 100644
--- a/pkg/api/handlers/libpod/swagger.go
+++ b/pkg/api/handlers/libpod/swagger.go
@@ -4,9 +4,9 @@ import (
"net/http"
"os"
- "github.com/containernetworking/cni/libcni"
"github.com/containers/image/v5/manifest"
"github.com/containers/podman/v3/libpod/define"
+ "github.com/containers/podman/v3/libpod/network/types"
"github.com/containers/podman/v3/pkg/api/handlers/utils"
"github.com/containers/podman/v3/pkg/domain/entities"
"github.com/pkg/errors"
@@ -103,21 +103,27 @@ type swagNetworkRmReport struct {
// swagger:response NetworkInspectReport
type swagNetworkInspectReport struct {
// in:body
- Body libcni.NetworkConfigList
+ Body types.Network
}
// Network list
// swagger:response NetworkListReport
type swagNetworkListReport struct {
// in:body
- Body []entities.NetworkListReport
+ Body []types.Network
+}
+
+// Network create
+// swagger:model NetworkCreateLibpod
+type swagNetworkCreateLibpod struct {
+ types.Network
}
// Network create
// swagger:response NetworkCreateReport
type swagNetworkCreateReport struct {
// in:body
- Body entities.NetworkCreateReport
+ Body types.Network
}
// Network prune