Skip to content

Commit

Permalink
Drop APIv2 resize endpoint
Browse files Browse the repository at this point in the history
Jhon is working on an alternative version that will combine
container and exec session resize, so we'll wait for that.

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
  • Loading branch information
mheon authored and joequant committed May 17, 2020
1 parent 6866d14 commit 954e047
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 44 deletions.
41 changes: 0 additions & 41 deletions pkg/api/handlers/compat/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@ import (
"github.com/containers/libpod/pkg/api/handlers"
"github.com/containers/libpod/pkg/api/handlers/utils"
"github.com/gorilla/mux"
"github.com/gorilla/schema"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"k8s.io/client-go/tools/remotecommand"
)

// ExecCreateHandler creates an exec session for a given container.
Expand Down Expand Up @@ -117,45 +115,6 @@ func ExecInspectHandler(w http.ResponseWriter, r *http.Request) {
}
}

// ExecResizeHandler resizes a given exec session's TTY.
func ExecResizeHandler(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"]

query := struct {
Height uint16 `schema:"h"`
Width uint16 `schema:"w"`
}{
// 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
}

sessionCtr, err := runtime.GetExecSessionContainer(sessionID)
if err != nil {
utils.Error(w, fmt.Sprintf("No such exec session: %s", sessionID), http.StatusNotFound, err)
return
}

newSize := remotecommand.TerminalSize{
Width: query.Width,
Height: query.Height,
}

if err := sessionCtr.ExecResize(sessionID, newSize); err != nil {
utils.InternalServerError(w, err)
return
}

// This is a 201 some reason, not a 204.
utils.WriteResponse(w, http.StatusCreated, "")
}

// ExecStartHandler runs a given exec session.
func ExecStartHandler(w http.ResponseWriter, r *http.Request) {
runtime := r.Context().Value("runtime").(*libpod.Runtime)
Expand Down
6 changes: 3 additions & 3 deletions pkg/api/server/register_exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,9 @@ func (s *APIServer) registerExecHandlers(r *mux.Router) error {
// $ref: "#/responses/NoSuchExecInstance"
// 500:
// $ref: "#/responses/InternalError"
r.Handle(VersionedPath("/exec/{id}/resize"), s.APIHandler(compat.ExecResizeHandler)).Methods(http.MethodPost)
r.Handle(VersionedPath("/exec/{id}/resize"), s.APIHandler(compat.UnsupportedHandler)).Methods(http.MethodPost)
// Added non version path to URI to support docker non versioned paths
r.Handle("/exec/{id}/resize", s.APIHandler(compat.ExecResizeHandler)).Methods(http.MethodPost)
r.Handle("/exec/{id}/resize", s.APIHandler(compat.UnsupportedHandler)).Methods(http.MethodPost)
// swagger:operation GET /exec/{id}/json compat inspectExec
// ---
// tags:
Expand Down Expand Up @@ -310,7 +310,7 @@ func (s *APIServer) registerExecHandlers(r *mux.Router) error {
// $ref: "#/responses/NoSuchExecInstance"
// 500:
// $ref: "#/responses/InternalError"
r.Handle(VersionedPath("/libpod/exec/{id}/resize"), s.APIHandler(compat.ExecResizeHandler)).Methods(http.MethodPost)
r.Handle(VersionedPath("/libpod/exec/{id}/resize"), s.APIHandler(compat.UnsupportedHandler)).Methods(http.MethodPost)
// swagger:operation GET /libpod/exec/{id}/json libpod libpodInspectExec
// ---
// tags:
Expand Down

0 comments on commit 954e047

Please sign in to comment.