summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@gmail.com>2018-03-07 11:23:05 -0500
committerAtomic Bot <atomic-devel@projectatomic.io>2018-03-08 16:40:21 +0000
commitfcc36633557fd52daa2f48dbeb991d89fd5645bc (patch)
tree972781cb2f2a3fe4fa8acc146f0d0d1a1321c2b7
parent221a3ab2b527e8a8877427c20820cdc19d7bae42 (diff)
downloadpodman-fcc36633557fd52daa2f48dbeb991d89fd5645bc.tar.gz
podman-fcc36633557fd52daa2f48dbeb991d89fd5645bc.tar.bz2
podman-fcc36633557fd52daa2f48dbeb991d89fd5645bc.zip
Move internal function resizeTty to container_internal
Signed-off-by: Matthew Heon <matthew.heon@gmail.com> Closes: #462 Approved by: baude
-rw-r--r--libpod/container_api.go27
-rw-r--r--libpod/container_internal.go30
2 files changed, 30 insertions, 27 deletions
diff --git a/libpod/container_api.go b/libpod/container_api.go
index 9020a2dde..161cd938c 100644
--- a/libpod/container_api.go
+++ b/libpod/container_api.go
@@ -3,13 +3,11 @@ package libpod
import (
"io/ioutil"
"os"
- gosignal "os/signal"
"strconv"
"time"
"github.com/containers/storage"
"github.com/docker/docker/daemon/caps"
- "github.com/docker/docker/pkg/signal"
"github.com/docker/docker/pkg/stringid"
"github.com/docker/docker/pkg/term"
"github.com/pkg/errors"
@@ -322,31 +320,6 @@ func (c *Container) Exec(tty, privileged bool, env, cmd []string, user string) e
return waitErr
}
-func resizeTty(resize chan remotecommand.TerminalSize) {
- sigchan := make(chan os.Signal, 1)
- gosignal.Notify(sigchan, signal.SIGWINCH)
- sendUpdate := func() {
- winsize, err := term.GetWinsize(os.Stdin.Fd())
- if err != nil {
- logrus.Warnf("Could not get terminal size %v", err)
- return
- }
- resize <- remotecommand.TerminalSize{
- Width: winsize.Width,
- Height: winsize.Height,
- }
- }
- go func() {
- defer close(resize)
- // Update the terminal size immediately without waiting
- // for a SIGWINCH to get the correct initial size.
- sendUpdate()
- for range sigchan {
- sendUpdate()
- }
- }()
-}
-
// Attach attaches to a container
// Returns fully qualified URL of streaming server for the container
func (c *Container) Attach(noStdin bool, keys string, attached chan<- bool) error {
diff --git a/libpod/container_internal.go b/libpod/container_internal.go
index 772eeaa66..736655f13 100644
--- a/libpod/container_internal.go
+++ b/libpod/container_internal.go
@@ -6,6 +6,7 @@ import (
"io"
"io/ioutil"
"os"
+ gosignal "os/signal"
"path/filepath"
"strings"
"syscall"
@@ -16,7 +17,9 @@ import (
"github.com/containers/storage/pkg/chrootarchive"
"github.com/docker/docker/pkg/mount"
"github.com/docker/docker/pkg/namesgenerator"
+ "github.com/docker/docker/pkg/signal"
"github.com/docker/docker/pkg/stringid"
+ "github.com/docker/docker/pkg/term"
spec "github.com/opencontainers/runtime-spec/specs-go"
"github.com/opencontainers/runtime-tools/generate"
"github.com/opencontainers/selinux/go-selinux/label"
@@ -26,6 +29,7 @@ import (
"github.com/sirupsen/logrus"
"github.com/ulule/deepcopier"
"golang.org/x/sys/unix"
+ "k8s.io/client-go/tools/remotecommand"
)
const (
@@ -329,6 +333,32 @@ func (c *Container) stop(timeout uint) error {
return c.cleanupStorage()
}
+// resizeTty handles TTY resizing for Attach()
+func resizeTty(resize chan remotecommand.TerminalSize) {
+ sigchan := make(chan os.Signal, 1)
+ gosignal.Notify(sigchan, signal.SIGWINCH)
+ sendUpdate := func() {
+ winsize, err := term.GetWinsize(os.Stdin.Fd())
+ if err != nil {
+ logrus.Warnf("Could not get terminal size %v", err)
+ return
+ }
+ resize <- remotecommand.TerminalSize{
+ Width: winsize.Width,
+ Height: winsize.Height,
+ }
+ }
+ go func() {
+ defer close(resize)
+ // Update the terminal size immediately without waiting
+ // for a SIGWINCH to get the correct initial size.
+ sendUpdate()
+ for range sigchan {
+ sendUpdate()
+ }
+ }()
+}
+
// mountStorage sets up the container's root filesystem
// It mounts the image and any other requested mounts
// TODO: Add ability to override mount label so we can use this for Mount() too