1
0
mirror of https://github.com/bingohuang/docker-labs.git synced 2025-10-05 09:53:21 +08:00

Attach to the same terminal

This commit is contained in:
Jonathan Leibiusky (@xetorthio)
2016-10-08 13:35:02 +02:00
parent 7bbb284128
commit 02d50073c5
3 changed files with 25 additions and 12 deletions

View File

@@ -12,9 +12,22 @@ import (
// Echo the data received on the WebSocket.
func Exec(ws *websocket.Conn) {
id := bone.GetValue(ws.Request(), "instanceId")
sessionId := bone.GetValue(ws.Request(), "sessionId")
instanceId := bone.GetValue(ws.Request(), "instanceId")
ctx := context.Background()
conn, err := services.GetExecConnection(id, ctx)
session := services.GetSession(sessionId)
instance := services.GetInstance(session, instanceId)
if instance.ExecId == "" {
execId, err := services.CreateExecConnection(instance.Name, ctx)
if err != nil {
return
}
instance.ExecId = execId
}
conn, err := services.AttachExecConnection(instance.ExecId, ctx)
if err != nil {
return
}