mirror of
https://github.com/containers/podman.git
synced 2025-10-20 20:54:45 +08:00
move handleTerminalAttach to generic build
Signed-off-by: Peter Hunt <pehunt@redhat.com>
This commit is contained in:
@ -7,6 +7,7 @@ import (
|
|||||||
|
|
||||||
"github.com/docker/docker/pkg/signal"
|
"github.com/docker/docker/pkg/signal"
|
||||||
"github.com/docker/docker/pkg/term"
|
"github.com/docker/docker/pkg/term"
|
||||||
|
"github.com/pkg/errors"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"k8s.io/client-go/tools/remotecommand"
|
"k8s.io/client-go/tools/remotecommand"
|
||||||
)
|
)
|
||||||
@ -76,3 +77,25 @@ func (f *RawTtyFormatter) Format(entry *logrus.Entry) ([]byte, error) {
|
|||||||
|
|
||||||
return bytes, err
|
return bytes, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func handleTerminalAttach(ctx context.Context, resize chan remotecommand.TerminalSize) (context.CancelFunc, *term.State, error) {
|
||||||
|
logrus.Debugf("Handling terminal attach")
|
||||||
|
|
||||||
|
subCtx, cancel := context.WithCancel(ctx)
|
||||||
|
|
||||||
|
resizeTty(subCtx, resize)
|
||||||
|
|
||||||
|
oldTermState, err := term.SaveState(os.Stdin.Fd())
|
||||||
|
if err != nil {
|
||||||
|
// allow caller to not have to do any cleaning up if we error here
|
||||||
|
cancel()
|
||||||
|
return nil, nil, errors.Wrapf(err, "unable to save terminal state")
|
||||||
|
}
|
||||||
|
|
||||||
|
logrus.SetFormatter(&RawTtyFormatter{})
|
||||||
|
if _, err := term.SetRawTerminal(os.Stdin.Fd()); err != nil {
|
||||||
|
return cancel, nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return cancel, oldTermState, nil
|
||||||
|
}
|
||||||
|
@ -6,7 +6,6 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/containers/libpod/libpod"
|
"github.com/containers/libpod/libpod"
|
||||||
"github.com/docker/docker/pkg/term"
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"golang.org/x/crypto/ssh/terminal"
|
"golang.org/x/crypto/ssh/terminal"
|
||||||
@ -108,25 +107,3 @@ func StartAttachCtr(ctx context.Context, ctr *libpod.Container, stdout, stderr,
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func handleTerminalAttach(ctx context.Context, resize chan remotecommand.TerminalSize) (context.CancelFunc, *term.State, error) {
|
|
||||||
logrus.Debugf("Handling terminal attach")
|
|
||||||
|
|
||||||
subCtx, cancel := context.WithCancel(ctx)
|
|
||||||
|
|
||||||
resizeTty(subCtx, resize)
|
|
||||||
|
|
||||||
oldTermState, err := term.SaveState(os.Stdin.Fd())
|
|
||||||
if err != nil {
|
|
||||||
// allow caller to not have to do any cleaning up if we error here
|
|
||||||
cancel()
|
|
||||||
return nil, nil, errors.Wrapf(err, "unable to save terminal state")
|
|
||||||
}
|
|
||||||
|
|
||||||
logrus.SetFormatter(&RawTtyFormatter{})
|
|
||||||
if _, err := term.SetRawTerminal(os.Stdin.Fd()); err != nil {
|
|
||||||
return cancel, nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
return cancel, oldTermState, nil
|
|
||||||
}
|
|
||||||
|
Reference in New Issue
Block a user