mirror of
https://github.com/containers/podman.git
synced 2025-06-23 02:18:13 +08:00
Merge pull request #4915 from baude/reviewcorrections
[CI:DOCS]First pass at review comments
This commit is contained in:
@ -74,8 +74,25 @@ func TagImage(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
func RemoveImage(w http.ResponseWriter, r *http.Request) {
|
||||
decoder := r.Context().Value("decoder").(*schema.Decoder)
|
||||
runtime := r.Context().Value("runtime").(*libpod.Runtime)
|
||||
|
||||
query := struct {
|
||||
noPrune bool
|
||||
}{
|
||||
// This is where you can override the golang default value for one of fields
|
||||
}
|
||||
|
||||
if err := decoder.Decode(&query, r.URL.Query()); err != nil {
|
||||
utils.Error(w, "Something went wrong.", http.StatusBadRequest, errors.Wrapf(err, "Failed to parse parameters for %s", r.URL.String()))
|
||||
return
|
||||
}
|
||||
muxVars := mux.Vars(r)
|
||||
if _, found := muxVars["noprune"]; found {
|
||||
if query.noPrune {
|
||||
utils.UnSupportedParameter("noprune")
|
||||
}
|
||||
}
|
||||
name := mux.Vars(r)["name"]
|
||||
newImage, err := runtime.ImageRuntime().NewFromLocal(name)
|
||||
if err != nil {
|
||||
|
@ -143,6 +143,22 @@ func CreateContainer(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
}
|
||||
|
||||
func UnmountContainer(w http.ResponseWriter, r *http.Request) {
|
||||
runtime := r.Context().Value("runtime").(*libpod.Runtime)
|
||||
name := mux.Vars(r)["name"]
|
||||
conn, err := runtime.LookupContainer(name)
|
||||
if err != nil {
|
||||
utils.ContainerNotFound(w, name, err)
|
||||
return
|
||||
}
|
||||
// TODO In future it might be an improvement that libpod unmount return a
|
||||
// "container not mounted" error so we can surface that to the endpoint user
|
||||
if err := conn.Unmount(false); err != nil {
|
||||
utils.InternalServerError(w, err)
|
||||
}
|
||||
utils.WriteResponse(w, http.StatusNoContent, "")
|
||||
|
||||
}
|
||||
func MountContainer(w http.ResponseWriter, r *http.Request) {
|
||||
runtime := r.Context().Value("runtime").(*libpod.Runtime)
|
||||
name := mux.Vars(r)["name"]
|
||||
|
@ -12,6 +12,7 @@ import (
|
||||
"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/util"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/gorilla/schema"
|
||||
"github.com/pkg/errors"
|
||||
@ -384,18 +385,27 @@ func PodKill(w http.ResponseWriter, r *http.Request) {
|
||||
var (
|
||||
runtime = r.Context().Value("runtime").(*libpod.Runtime)
|
||||
decoder = r.Context().Value("decoder").(*schema.Decoder)
|
||||
signal = "SIGKILL"
|
||||
)
|
||||
query := struct {
|
||||
signal int `schema:"signal"`
|
||||
signal string `schema:"signal"`
|
||||
}{
|
||||
// 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
|
||||
}
|
||||
muxVars := mux.Vars(r)
|
||||
if _, found := muxVars["signal"]; found {
|
||||
signal = query.signal
|
||||
}
|
||||
|
||||
sig, err := util.ParseSignal(signal)
|
||||
if err != nil {
|
||||
utils.InternalServerError(w, errors.Wrapf(err, "unable to parse signal value"))
|
||||
}
|
||||
name := mux.Vars(r)["name"]
|
||||
pod, err := runtime.LookupPod(name)
|
||||
if err != nil {
|
||||
@ -419,8 +429,7 @@ func PodKill(w http.ResponseWriter, r *http.Request) {
|
||||
utils.Error(w, msg, http.StatusConflict, errors.Errorf("cannot kill a pod with no running containers: %s", pod.ID()))
|
||||
return
|
||||
}
|
||||
// TODO How do we differentiate if a signal was sent vs accepting the pod/container default?
|
||||
_, err = pod.Kill(uint(query.signal))
|
||||
_, err = pod.Kill(uint(sig))
|
||||
if err != nil {
|
||||
utils.Error(w, "Something went wrong", http.StatusInternalServerError, err)
|
||||
return
|
||||
|
@ -30,9 +30,7 @@ type swagImageInspect struct {
|
||||
// swagger:response DocsImageDeleteResponse
|
||||
type swagImageDeleteResponse struct {
|
||||
// in:body
|
||||
Body struct {
|
||||
image.ImageDeleteResponse
|
||||
}
|
||||
Body []image.ImageDeleteResponse
|
||||
}
|
||||
|
||||
// Search results
|
||||
|
@ -86,3 +86,8 @@ func (e ErrorModel) Error() string {
|
||||
func (e ErrorModel) Cause() error {
|
||||
return errors.New(e.Because)
|
||||
}
|
||||
|
||||
// UnsupportedParameter logs a given param by its string name as not supported.
|
||||
func UnSupportedParameter(param string) {
|
||||
log.Infof("API parameter %q: not supported", param)
|
||||
}
|
||||
|
@ -665,7 +665,7 @@ func (s *APIServer) RegisterContainersHandlers(r *mux.Router) error {
|
||||
// '500':
|
||||
// "$ref": "#/responses/InternalError"
|
||||
r.HandleFunc(VersionedPath("/libpod/containers/{name:..*}/kill"), APIHandler(s.Context, libpod.KillContainer)).Methods(http.MethodGet)
|
||||
// swagger:operation GET /libpod/containers/{nameOrID}/mount libpod mountContainer
|
||||
// swagger:operation POST /libpod/containers/{nameOrID}/mount libpod mountContainer
|
||||
// ---
|
||||
// tags:
|
||||
// - containers
|
||||
@ -684,12 +684,33 @@ func (s *APIServer) RegisterContainersHandlers(r *mux.Router) error {
|
||||
// schema:
|
||||
// description: id
|
||||
// type: string
|
||||
// example: 3c784de79b791b4ebd3ac55e511f97fedc042328499554937a3f8bfd9c1a2cb8
|
||||
// example: /var/lib/containers/storage/overlay/f3f693bd88872a1e3193f4ebb925f4c282e8e73aadb8ab3e7492754dda3a02a4/merged
|
||||
// '404':
|
||||
// "$ref": "#/responses/NoSuchContainer"
|
||||
// '500':
|
||||
// "$ref": "#/responses/InternalError"
|
||||
r.HandleFunc(VersionedPath("/libpod/containers/{name:..*}/mount"), APIHandler(s.Context, libpod.MountContainer)).Methods(http.MethodPost)
|
||||
// swagger:operation GET /libpod/containers/{nameOrID}/unmount libpod unmountContainer
|
||||
// ---
|
||||
// tags:
|
||||
// - containers
|
||||
// summary: Unmount a container
|
||||
// description: Unmount a container from the filesystem
|
||||
// parameters:
|
||||
// - in: path
|
||||
// name: nameOrID
|
||||
// required: true
|
||||
// description: the name or ID of the container
|
||||
// produces:
|
||||
// - application/json
|
||||
// responses:
|
||||
// '204':
|
||||
// description: no error
|
||||
// '404':
|
||||
// "$ref": "#/responses/NoSuchContainer"
|
||||
// '500':
|
||||
// "$ref": "#/responses/InternalError"
|
||||
r.HandleFunc(VersionedPath("/libpod/containers/{name:..*}/unmount"), APIHandler(s.Context, libpod.UnmountContainer)).Methods(http.MethodPost)
|
||||
r.HandleFunc(VersionedPath("/libpod/containers/{name:..*}/logs"), APIHandler(s.Context, libpod.LogsFromContainer)).Methods(http.MethodGet)
|
||||
// swagger:operation POST /libpod/containers/{nameOrID}/pause libpod libpodPauseContainer
|
||||
// ---
|
||||
|
@ -193,8 +193,8 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error {
|
||||
// responses:
|
||||
// '200':
|
||||
// $ref: "#/responses/DocsImageDeleteResponse"
|
||||
// '400':
|
||||
// $ref: '#/responses/BadParamError'
|
||||
// '404':
|
||||
// $ref: '#/responses/NoSuchImage'
|
||||
// '409':
|
||||
// $ref: '#/responses/ConflictError'
|
||||
// '500':
|
||||
@ -506,11 +506,7 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error {
|
||||
// - application/json
|
||||
// responses:
|
||||
// '200':
|
||||
// schema:
|
||||
// items:
|
||||
// $ref: "#/responses/DocsIageDeleteResponse"
|
||||
// '400':
|
||||
// $ref: "#/responses/BadParamError"
|
||||
// $ref: "#/responses/DocsImageDeleteResponse"
|
||||
// '404':
|
||||
// $ref: '#/responses/NoSuchImage'
|
||||
// '409':
|
||||
@ -533,10 +529,12 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error {
|
||||
// name: format
|
||||
// type: string
|
||||
// description: format for exported image
|
||||
// default: oci-archive
|
||||
// - in: query
|
||||
// name: compress
|
||||
// type: bool
|
||||
// description: use compression on image
|
||||
// default: false
|
||||
// produces:
|
||||
// - application/json
|
||||
// responses:
|
||||
|
@ -121,8 +121,9 @@ func (s *APIServer) registerPodsHandlers(r *mux.Router) error {
|
||||
// description: the name or ID of the pod
|
||||
// - in: query
|
||||
// name: signal
|
||||
// type: int
|
||||
// type: string
|
||||
// description: signal to be sent to pod
|
||||
// default: SIGKILL
|
||||
// responses:
|
||||
// '204':
|
||||
// description: no error
|
||||
|
Reference in New Issue
Block a user