Skip to content

Commit

Permalink
more cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
luke-lombardi committed Dec 31, 2024
1 parent f296b47 commit e703380
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions pkg/abstractions/shell/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,9 @@ func (g *shellGroup) ShellConnect(ctx echo.Context) error {
return apiv1.HTTPNotFound()
}

log.Println("stubId", stubId)

// TODO: auth by stub ID

// Create a context with a 5-minute timeout
timeoutCtx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
defer cancel()

// Use the new method to wait for the container to be running
err = g.ss.waitForContainerRunning(timeoutCtx, containerId, 5*time.Second)
if err != nil {
return ctx.String(http.StatusBadGateway, err.Error())
Expand All @@ -68,12 +62,12 @@ func (g *shellGroup) ShellConnect(ctx echo.Context) error {
// Hijack the connection
hijacker, ok := ctx.Response().Writer.(http.Hijacker)
if !ok {
return ctx.String(http.StatusInternalServerError, "Webserver doesn't support hijacking")
return ctx.String(http.StatusInternalServerError, "Failed to create tunnel")
}

conn, _, err := hijacker.Hijack()
if err != nil {
return ctx.String(http.StatusInternalServerError, "Failed to hijack connection")
return ctx.String(http.StatusInternalServerError, "Failed to create tunnel")
}
defer conn.Close()

Expand Down

0 comments on commit e703380

Please sign in to comment.