summaryrefslogtreecommitdiff
path: root/pkg/api
diff options
context:
space:
mode:
authorBrent Baude <bbaude@redhat.com>2020-03-20 12:37:37 -0500
committerBrent Baude <bbaude@redhat.com>2020-03-20 18:27:08 -0500
commitc3a9ff11743c1ee25515ced348ec635fb7703aa0 (patch)
tree380dedfa9ffb337ebe197b15c218b3a1bfc627b6 /pkg/api
parent7a095af92a6a39845b1c362222b23632f3e17001 (diff)
downloadpodman-c3a9ff11743c1ee25515ced348ec635fb7703aa0.tar.gz
podman-c3a9ff11743c1ee25515ced348ec635fb7703aa0.tar.bz2
podman-c3a9ff11743c1ee25515ced348ec635fb7703aa0.zip
podmanv2 volume create
add volume create Signed-off-by: Brent Baude <bbaude@redhat.com>
Diffstat (limited to 'pkg/api')
-rw-r--r--pkg/api/handlers/libpod/volumes.go20
-rw-r--r--pkg/api/handlers/types.go12
-rw-r--r--pkg/api/server/swagger.go3
3 files changed, 17 insertions, 18 deletions
diff --git a/pkg/api/handlers/libpod/volumes.go b/pkg/api/handlers/libpod/volumes.go
index 9b10ee890..06ca1d225 100644
--- a/pkg/api/handlers/libpod/volumes.go
+++ b/pkg/api/handlers/libpod/volumes.go
@@ -8,8 +8,8 @@ import (
"github.com/containers/libpod/cmd/podman/shared"
"github.com/containers/libpod/libpod"
"github.com/containers/libpod/libpod/define"
- "github.com/containers/libpod/pkg/api/handlers"
"github.com/containers/libpod/pkg/api/handlers/utils"
+ "github.com/containers/libpod/pkg/domain/entities"
"github.com/gorilla/schema"
"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
@@ -25,7 +25,7 @@ func CreateVolume(w http.ResponseWriter, r *http.Request) {
}{
// override any golang type defaults
}
- input := handlers.VolumeCreateConfig{}
+ input := entities.VolumeCreateOptions{}
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()))
@@ -46,8 +46,8 @@ func CreateVolume(w http.ResponseWriter, r *http.Request) {
if len(input.Label) > 0 {
volumeOptions = append(volumeOptions, libpod.WithVolumeLabels(input.Label))
}
- if len(input.Opts) > 0 {
- parsedOptions, err := shared.ParseVolumeOptions(input.Opts)
+ if len(input.Options) > 0 {
+ parsedOptions, err := shared.ParseVolumeOptions(input.Options)
if err != nil {
utils.InternalServerError(w, err)
return
@@ -64,7 +64,17 @@ func CreateVolume(w http.ResponseWriter, r *http.Request) {
utils.InternalServerError(w, err)
return
}
- utils.WriteResponse(w, http.StatusOK, config)
+ volResponse := entities.VolumeConfigResponse{
+ Name: config.Name,
+ Labels: config.Labels,
+ Driver: config.Driver,
+ MountPoint: config.MountPoint,
+ CreatedTime: config.CreatedTime,
+ Options: config.Options,
+ UID: config.UID,
+ GID: config.GID,
+ }
+ utils.WriteResponse(w, http.StatusOK, volResponse)
}
func InspectVolume(w http.ResponseWriter, r *http.Request) {
diff --git a/pkg/api/handlers/types.go b/pkg/api/handlers/types.go
index ce4a9957b..c6b70251b 100644
--- a/pkg/api/handlers/types.go
+++ b/pkg/api/handlers/types.go
@@ -128,18 +128,6 @@ type CreateContainerConfig struct {
NetworkingConfig dockerNetwork.NetworkingConfig
}
-// swagger:model VolumeCreate
-type VolumeCreateConfig struct {
- // New volume's name. Can be left blank
- Name string `schema:"name"`
- // Volume driver to use
- Driver string `schema:"driver"`
- // User-defined key/value metadata.
- Label map[string]string `schema:"label"`
- // Mapping of driver options and values.
- Opts map[string]string `schema:"opts"`
-}
-
// swagger:model IDResponse
type IDResponse struct {
// ID
diff --git a/pkg/api/server/swagger.go b/pkg/api/server/swagger.go
index d2cf7503e..2e1a269f2 100644
--- a/pkg/api/server/swagger.go
+++ b/pkg/api/server/swagger.go
@@ -4,6 +4,7 @@ import (
"github.com/containers/libpod/libpod"
"github.com/containers/libpod/pkg/api/handlers"
"github.com/containers/libpod/pkg/api/handlers/utils"
+ "github.com/containers/libpod/pkg/domain/entities"
)
// No such image
@@ -155,7 +156,7 @@ type ok struct {
type swagVolumeCreateResponse struct {
// in:body
Body struct {
- libpod.VolumeConfig
+ entities.VolumeConfigResponse
}
}