summaryrefslogtreecommitdiff
path: root/pkg/api/handlers/utils/containers.go
diff options
context:
space:
mode:
authorJhon Honce <jhonce@redhat.com>2020-03-09 14:18:44 +0100
committerJhon Honce <jhonce@redhat.com>2020-03-10 08:03:41 -0700
commit31112e4b087612f7d63e83d770263b8b9fa4f206 (patch)
treee27af2df4e9c2c24f6a245e245ccc96d5fe1706b /pkg/api/handlers/utils/containers.go
parent684813fb3effbd7a483e44233ed395eb49c7fded (diff)
downloadpodman-31112e4b087612f7d63e83d770263b8b9fa4f206.tar.gz
podman-31112e4b087612f7d63e83d770263b8b9fa4f206.tar.bz2
podman-31112e4b087612f7d63e83d770263b8b9fa4f206.zip
Refactor handler packages
To help with packaging, the handlers in pkg/api/handlers are now found in pkg/api/handler/compat. Signed-off-by: Jhon Honce <jhonce@redhat.com>
Diffstat (limited to 'pkg/api/handlers/utils/containers.go')
-rw-r--r--pkg/api/handlers/utils/containers.go56
1 files changed, 0 insertions, 56 deletions
diff --git a/pkg/api/handlers/utils/containers.go b/pkg/api/handlers/utils/containers.go
index 07efef0f5..d5a79bdc8 100644
--- a/pkg/api/handlers/utils/containers.go
+++ b/pkg/api/handlers/utils/containers.go
@@ -2,9 +2,7 @@ package utils
import (
"context"
- "fmt"
"net/http"
- "syscall"
"time"
"github.com/containers/libpod/cmd/podman/shared"
@@ -23,60 +21,6 @@ type ContainerCreateResponse struct {
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)
- query := struct {
- Signal syscall.Signal `schema:"signal"`
- }{
- Signal: syscall.SIGKILL,
- }
- if err := decoder.Decode(&query, r.URL.Query()); err != nil {
- Error(w, "Something went wrong.", http.StatusBadRequest, errors.Wrapf(err, "Failed to parse parameters for %s", r.URL.String()))
- return nil, err
- }
- name := GetName(r)
- con, err := runtime.LookupContainer(name)
- if err != nil {
- ContainerNotFound(w, name, err)
- return nil, err
- }
-
- state, err := con.State()
- if err != nil {
- InternalServerError(w, err)
- return con, err
- }
-
- // If the Container is stopped already, send a 409
- if state == define.ContainerStateStopped || state == define.ContainerStateExited {
- Error(w, fmt.Sprintf("Container %s is not running", name), http.StatusConflict, errors.New(fmt.Sprintf("Cannot kill Container %s, it is not running", name)))
- return con, err
- }
-
- err = con.Kill(uint(query.Signal))
- if err != nil {
- Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrapf(err, "unable to kill Container %s", name))
- }
- return con, err
-}
-
-func RemoveContainer(w http.ResponseWriter, r *http.Request, force, vols bool) {
- runtime := r.Context().Value("runtime").(*libpod.Runtime)
- name := GetName(r)
- con, err := runtime.LookupContainer(name)
- if err != nil {
- ContainerNotFound(w, name, err)
- return
- }
-
- if err := runtime.RemoveContainer(r.Context(), con, force, vols); err != nil {
- InternalServerError(w, err)
- return
- }
- WriteResponse(w, http.StatusNoContent, "")
-}
-
func WaitContainer(w http.ResponseWriter, r *http.Request) (int32, error) {
var (
err error