From 08d04c2e0512cd67e81965f4f6aee26a83fd4046 Mon Sep 17 00:00:00 2001 From: Matthew Heon Date: Thu, 14 May 2020 16:50:44 -0400 Subject: 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 --- pkg/api/handlers/compat/exec.go | 24 +++++++----------------- pkg/api/handlers/types.go | 5 +++++ 2 files changed, 12 insertions(+), 17 deletions(-) (limited to 'pkg/api') 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 { -- cgit v1.2.3-54-g00ecf