diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2019-07-24 13:16:21 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-24 13:16:21 +0200 |
commit | eae9a009b2038d78a2cc92db740c99b1b8dc0101 (patch) | |
tree | 0bcbb02a1110495b7fb46eb4c8f3776a0849efaf /pkg/adapter/terminal.go | |
parent | 0d441f57d64bcca16c14ca44b7c8f35ab687ea3f (diff) | |
parent | 01a8483a59eed8bc706b5219b903704544b66c10 (diff) | |
download | podman-eae9a009b2038d78a2cc92db740c99b1b8dc0101.tar.gz podman-eae9a009b2038d78a2cc92db740c99b1b8dc0101.tar.bz2 podman-eae9a009b2038d78a2cc92db740c99b1b8dc0101.zip |
Merge pull request #3624 from haircommander/conmon-exec-with-remote-exec
Add remote exec
Diffstat (limited to 'pkg/adapter/terminal.go')
-rw-r--r-- | pkg/adapter/terminal.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/pkg/adapter/terminal.go b/pkg/adapter/terminal.go index 373c78322..51b747d23 100644 --- a/pkg/adapter/terminal.go +++ b/pkg/adapter/terminal.go @@ -7,6 +7,7 @@ import ( "github.com/docker/docker/pkg/signal" "github.com/docker/docker/pkg/term" + "github.com/pkg/errors" "github.com/sirupsen/logrus" "k8s.io/client-go/tools/remotecommand" ) @@ -76,3 +77,25 @@ func (f *RawTtyFormatter) Format(entry *logrus.Entry) ([]byte, error) { 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 +} |