mirror of
https://github.com/containers/podman.git
synced 2025-06-24 03:08: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) {
|
func RemoveImage(w http.ResponseWriter, r *http.Request) {
|
||||||
|
decoder := r.Context().Value("decoder").(*schema.Decoder)
|
||||||
runtime := r.Context().Value("runtime").(*libpod.Runtime)
|
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"]
|
name := mux.Vars(r)["name"]
|
||||||
newImage, err := runtime.ImageRuntime().NewFromLocal(name)
|
newImage, err := runtime.ImageRuntime().NewFromLocal(name)
|
||||||
if err != nil {
|
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) {
|
func MountContainer(w http.ResponseWriter, r *http.Request) {
|
||||||
runtime := r.Context().Value("runtime").(*libpod.Runtime)
|
runtime := r.Context().Value("runtime").(*libpod.Runtime)
|
||||||
name := mux.Vars(r)["name"]
|
name := mux.Vars(r)["name"]
|
||||||
|
@ -12,6 +12,7 @@ import (
|
|||||||
"github.com/containers/libpod/libpod/define"
|
"github.com/containers/libpod/libpod/define"
|
||||||
"github.com/containers/libpod/pkg/api/handlers"
|
"github.com/containers/libpod/pkg/api/handlers"
|
||||||
"github.com/containers/libpod/pkg/api/handlers/utils"
|
"github.com/containers/libpod/pkg/api/handlers/utils"
|
||||||
|
"github.com/containers/libpod/pkg/util"
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
"github.com/gorilla/schema"
|
"github.com/gorilla/schema"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
@ -384,18 +385,27 @@ func PodKill(w http.ResponseWriter, r *http.Request) {
|
|||||||
var (
|
var (
|
||||||
runtime = r.Context().Value("runtime").(*libpod.Runtime)
|
runtime = r.Context().Value("runtime").(*libpod.Runtime)
|
||||||
decoder = r.Context().Value("decoder").(*schema.Decoder)
|
decoder = r.Context().Value("decoder").(*schema.Decoder)
|
||||||
|
signal = "SIGKILL"
|
||||||
)
|
)
|
||||||
query := struct {
|
query := struct {
|
||||||
signal int `schema:"signal"`
|
signal string `schema:"signal"`
|
||||||
}{
|
}{
|
||||||
// override any golang type defaults
|
// override any golang type defaults
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := decoder.Decode(&query, r.URL.Query()); err != nil {
|
if err := decoder.Decode(&query, r.URL.Query()); err != nil {
|
||||||
utils.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest,
|
utils.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest,
|
||||||
errors.Wrapf(err, "Failed to parse parameters for %s", r.URL.String()))
|
errors.Wrapf(err, "Failed to parse parameters for %s", r.URL.String()))
|
||||||
return
|
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"]
|
name := mux.Vars(r)["name"]
|
||||||
pod, err := runtime.LookupPod(name)
|
pod, err := runtime.LookupPod(name)
|
||||||
if err != nil {
|
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()))
|
utils.Error(w, msg, http.StatusConflict, errors.Errorf("cannot kill a pod with no running containers: %s", pod.ID()))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// TODO How do we differentiate if a signal was sent vs accepting the pod/container default?
|
_, err = pod.Kill(uint(sig))
|
||||||
_, err = pod.Kill(uint(query.signal))
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.Error(w, "Something went wrong", http.StatusInternalServerError, err)
|
utils.Error(w, "Something went wrong", http.StatusInternalServerError, err)
|
||||||
return
|
return
|
||||||
|
@ -30,9 +30,7 @@ type swagImageInspect struct {
|
|||||||
// swagger:response DocsImageDeleteResponse
|
// swagger:response DocsImageDeleteResponse
|
||||||
type swagImageDeleteResponse struct {
|
type swagImageDeleteResponse struct {
|
||||||
// in:body
|
// in:body
|
||||||
Body struct {
|
Body []image.ImageDeleteResponse
|
||||||
image.ImageDeleteResponse
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Search results
|
// Search results
|
||||||
|
@ -86,3 +86,8 @@ func (e ErrorModel) Error() string {
|
|||||||
func (e ErrorModel) Cause() error {
|
func (e ErrorModel) Cause() error {
|
||||||
return errors.New(e.Because)
|
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':
|
// '500':
|
||||||
// "$ref": "#/responses/InternalError"
|
// "$ref": "#/responses/InternalError"
|
||||||
r.HandleFunc(VersionedPath("/libpod/containers/{name:..*}/kill"), APIHandler(s.Context, libpod.KillContainer)).Methods(http.MethodGet)
|
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:
|
// tags:
|
||||||
// - containers
|
// - containers
|
||||||
@ -684,12 +684,33 @@ func (s *APIServer) RegisterContainersHandlers(r *mux.Router) error {
|
|||||||
// schema:
|
// schema:
|
||||||
// description: id
|
// description: id
|
||||||
// type: string
|
// type: string
|
||||||
// example: 3c784de79b791b4ebd3ac55e511f97fedc042328499554937a3f8bfd9c1a2cb8
|
// example: /var/lib/containers/storage/overlay/f3f693bd88872a1e3193f4ebb925f4c282e8e73aadb8ab3e7492754dda3a02a4/merged
|
||||||
// '404':
|
// '404':
|
||||||
// "$ref": "#/responses/NoSuchContainer"
|
// "$ref": "#/responses/NoSuchContainer"
|
||||||
// '500':
|
// '500':
|
||||||
// "$ref": "#/responses/InternalError"
|
// "$ref": "#/responses/InternalError"
|
||||||
r.HandleFunc(VersionedPath("/libpod/containers/{name:..*}/mount"), APIHandler(s.Context, libpod.MountContainer)).Methods(http.MethodPost)
|
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)
|
r.HandleFunc(VersionedPath("/libpod/containers/{name:..*}/logs"), APIHandler(s.Context, libpod.LogsFromContainer)).Methods(http.MethodGet)
|
||||||
// swagger:operation POST /libpod/containers/{nameOrID}/pause libpod libpodPauseContainer
|
// swagger:operation POST /libpod/containers/{nameOrID}/pause libpod libpodPauseContainer
|
||||||
// ---
|
// ---
|
||||||
|
@ -193,8 +193,8 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error {
|
|||||||
// responses:
|
// responses:
|
||||||
// '200':
|
// '200':
|
||||||
// $ref: "#/responses/DocsImageDeleteResponse"
|
// $ref: "#/responses/DocsImageDeleteResponse"
|
||||||
// '400':
|
// '404':
|
||||||
// $ref: '#/responses/BadParamError'
|
// $ref: '#/responses/NoSuchImage'
|
||||||
// '409':
|
// '409':
|
||||||
// $ref: '#/responses/ConflictError'
|
// $ref: '#/responses/ConflictError'
|
||||||
// '500':
|
// '500':
|
||||||
@ -506,11 +506,7 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error {
|
|||||||
// - application/json
|
// - application/json
|
||||||
// responses:
|
// responses:
|
||||||
// '200':
|
// '200':
|
||||||
// schema:
|
// $ref: "#/responses/DocsImageDeleteResponse"
|
||||||
// items:
|
|
||||||
// $ref: "#/responses/DocsIageDeleteResponse"
|
|
||||||
// '400':
|
|
||||||
// $ref: "#/responses/BadParamError"
|
|
||||||
// '404':
|
// '404':
|
||||||
// $ref: '#/responses/NoSuchImage'
|
// $ref: '#/responses/NoSuchImage'
|
||||||
// '409':
|
// '409':
|
||||||
@ -533,10 +529,12 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error {
|
|||||||
// name: format
|
// name: format
|
||||||
// type: string
|
// type: string
|
||||||
// description: format for exported image
|
// description: format for exported image
|
||||||
|
// default: oci-archive
|
||||||
// - in: query
|
// - in: query
|
||||||
// name: compress
|
// name: compress
|
||||||
// type: bool
|
// type: bool
|
||||||
// description: use compression on image
|
// description: use compression on image
|
||||||
|
// default: false
|
||||||
// produces:
|
// produces:
|
||||||
// - application/json
|
// - application/json
|
||||||
// responses:
|
// responses:
|
||||||
|
@ -121,8 +121,9 @@ func (s *APIServer) registerPodsHandlers(r *mux.Router) error {
|
|||||||
// description: the name or ID of the pod
|
// description: the name or ID of the pod
|
||||||
// - in: query
|
// - in: query
|
||||||
// name: signal
|
// name: signal
|
||||||
// type: int
|
// type: string
|
||||||
// description: signal to be sent to pod
|
// description: signal to be sent to pod
|
||||||
|
// default: SIGKILL
|
||||||
// responses:
|
// responses:
|
||||||
// '204':
|
// '204':
|
||||||
// description: no error
|
// description: no error
|
||||||
|
Reference in New Issue
Block a user