mirror of
https://github.com/containers/podman.git
synced 2025-07-15 03:02:52 +08:00
apiv2 container create using specgen
this uses the specgen structure to create containers rather than the outdated createconfig. right now, only the apiv2 create is wired up. eventually the cli will also have to be done. Signed-off-by: Brent Baude <bbaude@redhat.com>
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"syscall"
|
||||
@ -9,10 +10,19 @@ import (
|
||||
"github.com/containers/libpod/cmd/podman/shared"
|
||||
"github.com/containers/libpod/libpod"
|
||||
"github.com/containers/libpod/libpod/define"
|
||||
createconfig "github.com/containers/libpod/pkg/spec"
|
||||
"github.com/gorilla/schema"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// ContainerCreateResponse is the response struct for creating a container
|
||||
type ContainerCreateResponse struct {
|
||||
// ID of the container created
|
||||
ID string `json:"id"`
|
||||
// Warnings during container creation
|
||||
Warnings []string `json:"Warnings"`
|
||||
}
|
||||
|
||||
func KillContainer(w http.ResponseWriter, r *http.Request) (*libpod.Container, error) {
|
||||
runtime := r.Context().Value("runtime").(*libpod.Runtime)
|
||||
decoder := r.Context().Value("decoder").(*schema.Decoder)
|
||||
@ -119,3 +129,18 @@ func GenerateFilterFuncsFromMap(r *libpod.Runtime, filters map[string][]string)
|
||||
}
|
||||
return filterFuncs, nil
|
||||
}
|
||||
|
||||
func CreateContainer(ctx context.Context, w http.ResponseWriter, runtime *libpod.Runtime, cc *createconfig.CreateConfig) {
|
||||
var pod *libpod.Pod
|
||||
ctr, err := shared.CreateContainerFromCreateConfig(runtime, cc, ctx, pod)
|
||||
if err != nil {
|
||||
Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "CreateContainerFromCreateConfig()"))
|
||||
return
|
||||
}
|
||||
|
||||
response := ContainerCreateResponse{
|
||||
ID: ctr.ID(),
|
||||
Warnings: []string{}}
|
||||
|
||||
WriteResponse(w, http.StatusCreated, response)
|
||||
}
|
||||
|
Reference in New Issue
Block a user