mirror of
https://github.com/containers/podman.git
synced 2025-06-20 17:13:43 +08:00
Jira RUN-1106 Container handlers updates
Mostly audit and minor changes to nil from "" Audit: - GET /containers/json ListContainers - POST /containers/create CreateContainer - GET /containers/{id}/json GetContainer - GET /containers/{id}/top TopContainer - GET /containers/{id}/logs LogsFromContainer - GET /containers/{id}/changes Changes - GET /containers/{id}/export ExportContainer - GET /containers/{id}/stats StatsContainer - POST /containers/{id}/resize ResizeTTY - POST /containers/{id}/start StartContainer - POST /containers/{id}/stop StopContainer - POST /containers/{id}/restart RestartContainer - POST /containers/{id}/kill KillContainer - POST /containers/{id}/update 404 not supported - POST /containers/{id}/rename 404 not supported - POST /containers/{id}/pause PauseContainer - POST /containers/{id}/unpause UnpauseContainer - POST /containers/{id}/attach AttachContainer - GET /containers/{id}/attach/ws 404 not supported - POST /containers/{id}/wait WaitContainer - DELETE /containers/{id} RemoveContainer - HEAD /containers/{id}/archive Archive - GET /containers/{id}/archive Archive - PUT /containers/{id}/archive Archive - POST /containers/prune PruneContainers Images etc PR's will follow. Signed-off-by: Jhon Honce <jhonce@redhat.com>
This commit is contained in:
@ -17,6 +17,7 @@ import (
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"github.com/docker/go-connections/nat"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/gorilla/schema"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
@ -73,7 +74,7 @@ func RemoveContainer(w http.ResponseWriter, r *http.Request) {
|
||||
utils.InternalServerError(w, err)
|
||||
return
|
||||
}
|
||||
utils.WriteResponse(w, http.StatusNoContent, "")
|
||||
utils.WriteResponse(w, http.StatusNoContent, nil)
|
||||
}
|
||||
|
||||
func ListContainers(w http.ResponseWriter, r *http.Request) {
|
||||
@ -207,7 +208,7 @@ func KillContainer(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
}
|
||||
// Success
|
||||
utils.WriteResponse(w, http.StatusNoContent, "")
|
||||
utils.WriteResponse(w, http.StatusNoContent, nil)
|
||||
}
|
||||
|
||||
func WaitContainer(w http.ResponseWriter, r *http.Request) {
|
||||
@ -215,8 +216,10 @@ func WaitContainer(w http.ResponseWriter, r *http.Request) {
|
||||
// /{version}/containers/(name)/wait
|
||||
exitCode, err := utils.WaitContainer(w, r)
|
||||
if err != nil {
|
||||
logrus.Warnf("failed to wait on container %q: %v", mux.Vars(r)["name"], err)
|
||||
return
|
||||
}
|
||||
|
||||
utils.WriteResponse(w, http.StatusOK, handlers.ContainerWaitOKBody{
|
||||
StatusCode: int(exitCode),
|
||||
Error: struct {
|
||||
|
@ -24,5 +24,5 @@ func PauseContainer(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
// Success
|
||||
utils.WriteResponse(w, http.StatusNoContent, "")
|
||||
utils.WriteResponse(w, http.StatusNoContent, nil)
|
||||
}
|
||||
|
@ -41,5 +41,5 @@ func RestartContainer(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
// Success
|
||||
utils.WriteResponse(w, http.StatusNoContent, "")
|
||||
utils.WriteResponse(w, http.StatusNoContent, nil)
|
||||
}
|
||||
|
@ -39,12 +39,12 @@ func StartContainer(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
if state == define.ContainerStateRunning {
|
||||
utils.WriteResponse(w, http.StatusNotModified, "")
|
||||
utils.WriteResponse(w, http.StatusNotModified, nil)
|
||||
return
|
||||
}
|
||||
if err := con.Start(r.Context(), len(con.PodID()) > 0); err != nil {
|
||||
utils.InternalServerError(w, err)
|
||||
return
|
||||
}
|
||||
utils.WriteResponse(w, http.StatusNoContent, "")
|
||||
utils.WriteResponse(w, http.StatusNoContent, nil)
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ func StopContainer(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
// If the Container is stopped already, send a 304
|
||||
if state == define.ContainerStateStopped || state == define.ContainerStateExited {
|
||||
utils.WriteResponse(w, http.StatusNotModified, "")
|
||||
utils.WriteResponse(w, http.StatusNotModified, nil)
|
||||
return
|
||||
}
|
||||
|
||||
@ -56,5 +56,5 @@ func StopContainer(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
// Success
|
||||
utils.WriteResponse(w, http.StatusNoContent, "")
|
||||
utils.WriteResponse(w, http.StatusNoContent, nil)
|
||||
}
|
||||
|
@ -24,5 +24,5 @@ func UnpauseContainer(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
// Success
|
||||
utils.WriteResponse(w, http.StatusNoContent, "")
|
||||
utils.WriteResponse(w, http.StatusNoContent, nil)
|
||||
}
|
||||
|
Reference in New Issue
Block a user