diff options
author | Matthew Heon <matthew.heon@pm.me> | 2020-05-14 16:50:44 -0400 |
---|---|---|
committer | Matthew Heon <matthew.heon@pm.me> | 2020-05-14 16:56:02 -0400 |
commit | 08d04c2e0512cd67e81965f4f6aee26a83fd4046 (patch) | |
tree | 9d6c0ea852bdcf11ecc700abfbde9d889f1b64dc | |
parent | 0f0abe290927cd17542953042885b554dbffd83e (diff) | |
download | podman-08d04c2e0512cd67e81965f4f6aee26a83fd4046.tar.gz podman-08d04c2e0512cd67e81965f4f6aee26a83fd4046.tar.bz2 podman-08d04c2e0512cd67e81965f4f6aee26a83fd4046.zip |
Parameters for ExecStart are body, not query
Oops. Misread the docs when I initially implemented this. Nice
and easy fix, at least.
Signed-off-by: Matthew Heon <matthew.heon@pm.me>
-rw-r--r-- | pkg/api/handlers/compat/exec.go | 24 | ||||
-rw-r--r-- | pkg/api/handlers/types.go | 5 |
2 files changed, 12 insertions, 17 deletions
diff --git a/pkg/api/handlers/compat/exec.go b/pkg/api/handlers/compat/exec.go index f97fecca2..6f62dca11 100644 --- a/pkg/api/handlers/compat/exec.go +++ b/pkg/api/handlers/compat/exec.go @@ -159,33 +159,23 @@ func ExecResizeHandler(w http.ResponseWriter, r *http.Request) { // ExecStartHandler runs a given exec session. func ExecStartHandler(w http.ResponseWriter, r *http.Request) { runtime := r.Context().Value("runtime").(*libpod.Runtime) - decoder := r.Context().Value("decoder").(*schema.Decoder) sessionID := mux.Vars(r)["id"] - // TODO: Need to support these - query := struct { - Detach bool `schema:"Detach"` - Tty bool `schema:"Tty"` - }{ - // 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 - } + // TODO: We should read/support Tty and Detach from here. + bodyParams := new(handlers.ExecStartConfig) - if _, found := r.URL.Query()["Detach"]; found { + if err := json.NewDecoder(r.Body).Decode(&bodyParams); err != nil { utils.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest, - errors.Errorf("Detached exec is not yet supported")) + errors.Wrapf(err, "failed to decode parameters for %s", r.URL.String())) return } - if _, found := r.URL.Query()["Tty"]; found { + if bodyParams.Detach == true { utils.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest, - errors.Errorf("overriding terminal setting in ExecStart is not yet supported")) + errors.Errorf("Detached exec is not yet supported")) return } + // TODO: Verify TTY setting against what inspect session was made with sessionCtr, err := runtime.GetExecSessionContainer(sessionID) if err != nil { diff --git a/pkg/api/handlers/types.go b/pkg/api/handlers/types.go index 2075d29df..d8cdd9caf 100644 --- a/pkg/api/handlers/types.go +++ b/pkg/api/handlers/types.go @@ -170,6 +170,11 @@ type ExecCreateResponse struct { docker.IDResponse } +type ExecStartConfig struct { + Detach bool `json:"Detach"` + Tty bool `json:"Tty"` +} + func ImageToImageSummary(l *libpodImage.Image) (*entities.ImageSummary, error) { containers, err := l.Containers() if err != nil { |