Commit graph

110 commits

Author SHA1 Message Date
Sebastiaan van Stijn
41d4112e89
pkg/term: vendor moby/term and make pkg/term an alias
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-04-21 16:29:19 +02:00
Sebastiaan van Stijn
701b39f5f0
pkg/term: deprecate package in favor of moby/term
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-04-21 16:24:18 +02:00
Bilal Amarni
8dd1490473 Support reading multiple bytes in escapeProxy
Currently, the escapeProxy works under the assumption that the
underlying reader will always return 1 byte at a time. Even though this
is usually true, it is not always the case, for example when using a pty
and writing multiple bytes to the master before flushing it.

In such cases the proxy reader doesn't work properly. For example with
an escape sequence being `ctrl-p,ctrl-q`, when the underlying reader
returns `ctrl-p,ctrl-q` at once, the escape sequence isn't detected.

This updates the reader to support this use-case and adds unit tests.

Signed-off-by: Bilal Amarni <bilal.amarni@gmail.com>
2020-03-18 00:19:53 +04:00
Sebastiaan van Stijn
9f0b3f5609
bump gotest.tools v3.0.1 for compatibility with Go 1.14
full diff: https://github.com/gotestyourself/gotest.tools/compare/v2.3.0...v3.0.1

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2020-02-11 00:06:42 +01:00
Sebastiaan van Stijn
739b7b44aa
pkg/term/windows: add missing build-tag
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-09-18 12:57:36 +02:00
Kir Kolyshkin
b5695b8663
pkg/term/term_linux_test: check returned error before deferring tty.Close() (staticcheck)
Fix the following warnings from staticcheck linter:

```
pkg/term/term_linux_test.go:34:2: SA5001: should check returned error before deferring tty.Close() (staticcheck)
	defer tty.Close()
	^
pkg/term/term_linux_test.go:52:2: SA5001: should check returned error before deferring tty.Close() (staticcheck)
 	defer tty.Close()
	^
pkg/term/term_linux_test.go:67:2: SA5001: should check returned error before deferring tty.Close() (staticcheck)
	defer tty.Close()
	^
....
```

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-09-18 12:57:14 +02:00
Sebastiaan van Stijn
07ff4f1de8
goimports: fix imports
Format the source according to latest goimports.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-09-18 12:56:54 +02:00
Sebastiaan van Stijn
556d26c07d
pkg/term: refactor TestEscapeProxyRead
- use subtests to make it clearer what the individual test-cases
  are, and to prevent tests from depending on values set by the
  previous test(s).
- remove redundant messages in assert (gotest.tools already prints
  a useful message if assertions fail).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2019-08-27 15:07:02 +02:00
Ximo Guanter Gonzálbez
ea65a0b134 Fix #28814
Signed-off-by: Ximo Guanter Gonzálbez <joaquin.guantergonzalbez@telefonica.com>
2018-08-07 10:20:13 +02:00
Vincent Demeester
3845728524
Update tests to use gotest.tools 👼
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
2018-06-13 09:04:30 +02:00
Sebastiaan van Stijn
f23c00d870
Various code-cleanup
remove unnescessary import aliases, brackets, and so on.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2018-05-23 17:50:54 +02:00
Patrik Cyvoct
d339130f30
Add verification and test to check if escapeKeys is not empty
In pkg/term/proxy.go and pkg/term/proxy_test.go, check if escapeKeys is empty and if it is, return the one key read

Signed-off-by: Patrik Cyvoct <patrik@ptrk.io>
2018-04-30 00:32:43 +02:00
Alexandre Jomin
0d82bc142c pkg/term add build tag for netbsd
Signed-off-by: Alexandre Jomin <alexandrejomin@gmail.com>
2018-04-18 15:16:06 +02:00
Daniel Nephin
c9e52bd0da Post migration assertion fixes
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2018-03-16 11:03:46 -04:00
Daniel Nephin
6be0f70983 Automated migration using
gty-migrate-from-testify --ignore-build-tags

Signed-off-by: Daniel Nephin <dnephin@docker.com>
2018-03-16 11:03:43 -04:00
Daniel Nephin
ef01dea893 Cleanup some assertions
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2018-03-16 10:54:54 -04:00
Daniel Nephin
4f0d95fa6e Add canonical import comment
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2018-02-05 16:51:57 -05:00
Sebastiaan van Stijn
6ed1163c98
Remove redundant build-tags
Files that are suffixed with `_linux.go` or `_windows.go` are
already only built on Linux / Windows, so these build-tags
were redundant.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2017-12-18 17:41:53 +01:00
Yong Tang
4785f1a7ab Remove solaris build tag and `contrib/mkimage/solaris
Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
2017-11-02 00:01:46 +00:00
Michael Crosby
5a9b5f10cf Remove solaris files
For obvious reasons that it is not really supported now.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-10-24 15:39:34 -04:00
Tobias Klauser
9335683fa5 Use all console mode constants from go-ansiterm
The missing console mode constants were added to go-ansiterm in
Azure/go-ansiterm#23. Use these constants instead of defining them
locally.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2017-10-02 09:49:20 +02:00
Daniel Nephin
09652bf878 Add ineffassign linter
Also enable GC in linting to reduce memory usage.

Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-09-08 18:23:21 -04:00
Brian Goff
a127269803 Merge pull request #34700 from tklauser/pkg-term-winsize
pkg/term: use IoctlGetWinsize/IoctlSetWinsize from golang.org/x/sys/unix
2017-09-01 15:58:25 -04:00
Tobias Klauser
32dfc0cb64 pkg/term: use IoctlGetWinsize/IoctlSetWinsize from golang.org/x/sys/unix
Use unix.IoctlGetWinsize and unix.IoctlSetWinsize instead of manually
reimplementing them.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2017-09-01 14:43:09 +02:00
Daniel Nephin
2f5f0af3fd Add unconvert linter
Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-08-24 15:08:31 -04:00
Tobias Klauser
8a3730d251 pkg/term: set termios VMIN and VTIME in MakeRaw on Linux
The BSD and Solaris versions of term.MakeRaw already set VMIN and VTIME
explicitly such that a read returns when one character is available.
cfmakeraw (which was previously used) in glibc also sets these values
explicitly, so it should be done in the Linux version of MakeRaw as well
to be consistent.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2017-08-03 13:21:42 +02:00
Derek McGowan
1009e6a40b
Update logrus to v1.0.1
Fixes case sensitivity issue

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2017-07-31 13:16:46 -07:00
Sebastiaan van Stijn
f8c434366e Merge pull request #33987 from dnephin/cleanup-more-hack
Move test-unit out of hack/make
2017-07-27 00:29:13 +02:00
Daniel Nephin
1fb615599a Remove test-unit from hack/make
Also remove the test flag from pkg/term and jsut checkuid directly.
Fixed a problem with a pkg/term test that was leaving the terminal in a bad
state.

Signed-off-by: Daniel Nephin <dnephin@docker.com>
2017-07-17 11:39:33 -04:00
Tobias Klauser
6476504695 [pkg/term] use IoctlGetTermios/IoctlSetTermios from x/sys/unix
Use IoctlGetTermios/IoctlSetTermios from golang.org/x/sys/unix instead
of manually reimplementing them.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2017-07-17 10:37:42 +02:00
Tobias Klauser
ef5252fc5d [pkg/term] temporarily use STD_*_HANDLE from syscall again
Due to the CL https://go-review.googlesource.com/c/39608/ in
x/sys/windows which changed the definitions of STD_INPUT_HANDLE,
STD_OUTPUT_HANDLE and STD_ERROR_HANDLE, we get the following failure
after re-vendoring x/sys/windows:

  07:47:01 # github.com/docker/docker/pkg/term
  07:47:01 pkg/term/term_windows.go:82: constant 4294967286 overflows int
  07:47:01 pkg/term/term_windows.go:88: constant 4294967285 overflows int
  07:47:01 pkg/term/term_windows.go:94: constant 4294967284 overflows int
  07:47:12 Build step 'Execute shell' marked build as failure

Temporarily switch back pkg/term to use these constants from the syscall
package and add a comment about it.

To really fix this, go-ansiterm should probably be switched to use
x/sys/windows.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
2017-07-12 14:52:42 +02:00
Michael Crosby
e57f8a78ae Merge pull request #33520 from naveed-jamil-tenpearls/pkg/term
Add test coverage to pkg/term
2017-06-08 13:41:49 -07:00
Naveed Jamil
a267248b5a Add test coverage to pkg/term/proxy.go
Signed-off-by: Naveed Jamil <naveed.jamil@tenpearls.com>
2017-06-08 12:48:33 +05:00
Michael Crosby
a5e83836a4 Revert ONCLR and OPOST changes
This reverts to a version of runc without the ONCLR cleared to not cause
a regression with different clients using --tty.

This also reverts the OPOST changes to the term package to support the
initial change.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-06-07 13:14:52 -07:00
Michael Crosby
17ec46a243 Set OPOST on bsd
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-06-02 12:53:49 -07:00
Christopher Jones
df6dfcf198
[pkg/term] switch more syscalls to /x/sys/
Switches the remaining syscalls except Errno to /x/sys/.
This was supposed to be part of 33180

Signed-off-by: Christopher Jones <tophj@linux.vnet.ibm.com>
2017-05-18 09:02:42 -04:00
Tibor Vass
6f6ee6fd04 Merge pull request #33180 from tophj-ibm/switch-pkg-term-syscalls-to-x/sys
[pkg/term] refactor and switch syscall to x/sys
2017-05-17 07:41:18 -07:00
Josh Hawn
4921171587 Update ContainerWait API
This patch adds the untilRemoved option to the ContainerWait API which
allows the client to wait until the container is not only exited but
also removed.

This patch also adds some more CLI integration tests for waiting for a
created container and waiting with the new --until-removed flag.

Docker-DCO-1.1-Signed-off-by: Josh Hawn <josh.hawn@docker.com> (github: jlhawn)

Handle detach sequence in CLI

Docker-DCO-1.1-Signed-off-by: Josh Hawn <josh.hawn@docker.com> (github: jlhawn)

Update Container Wait Conditions

Docker-DCO-1.1-Signed-off-by: Josh Hawn <josh.hawn@docker.com> (github: jlhawn)

Apply container wait changes to API 1.30

The set of changes to the containerWait API missed the cut for the
Docker 17.05 release (API version 1.29). This patch bumps the version
checks to use 1.30 instead.

This patch also makes a minor update to a testfile which was added to
the builder/dockerfile package.

Docker-DCO-1.1-Signed-off-by: Josh Hawn <josh.hawn@docker.com> (github: jlhawn)

Remove wait changes from CLI

Docker-DCO-1.1-Signed-off-by: Josh Hawn <josh.hawn@docker.com> (github: jlhawn)

Address minor nits on wait changes

- Changed the name of the tty Proxy wrapper to `escapeProxy`
- Removed the unnecessary Error() method on container.State
- Fixes a typo in comment (repeated word)

Docker-DCO-1.1-Signed-off-by: Josh Hawn <josh.hawn@docker.com> (github: jlhawn)

Use router.WithCancel in the containerWait handler

This handler previously added this functionality manually but now uses
the existing wrapper which does it for us.

Docker-DCO-1.1-Signed-off-by: Josh Hawn <josh.hawn@docker.com> (github: jlhawn)

Add WaitCondition constants to api/types/container

Docker-DCO-1.1-Signed-off-by: Josh Hawn <josh.hawn@docker.com> (github: jlhawn)

Address more ContainerWait review comments

- Update ContainerWait backend interface to not return pointer values
  for container.StateStatus type.
- Updated container state's Wait() method comments to clarify that a
  context MUST be used for cancelling the request, setting timeouts,
  and to avoid goroutine leaks.
- Removed unnecessary buffering when making channels in the client's
  ContainerWait methods.
- Renamed result and error channels in client's ContainerWait methods
  to clarify that only a single result or error value would be sent
  on the channel.

Docker-DCO-1.1-Signed-off-by: Josh Hawn <josh.hawn@docker.com> (github: jlhawn)

Move container.WaitCondition type to separate file

... to avoid conflict with swagger-generated code for API response

Docker-DCO-1.1-Signed-off-by: Josh Hawn <josh.hawn@docker.com> (github: jlhawn)

Address more ContainerWait review comments

Docker-DCO-1.1-Signed-off-by: Josh Hawn <josh.hawn@docker.com> (github: jlhawn)
2017-05-16 15:11:39 -07:00
Christopher Jones
1c94c264c4
Rename term to winsize, tc_other to tc
Signed-off-by: Christopher Jones <tophj@linux.vnet.ibm.com>
2017-05-16 11:46:17 -04:00
Tibor Vass
f8416e82d9 [pkg/term] Refactor BSD-specific files
Signed-off-by: Tibor Vass <tibor@docker.com>
2017-05-16 10:12:33 -04:00
Christopher Jones
f30b072b81
[pkg/term] switch syscall to x/sys
Switches calls to syscall to x/sys, which is more up to date.
This is fixes a number of possible bugs on other architectures
where ioctl tcget and tcset aren't implemented correctly.

There are a few remaining syscall references, because x/sys doesn't
have an Errno implementation yet.

Also removes a ppc64le and cgo build tag that fixes building on
ppc64le without cgo

Signed-off-by: Christopher Jones <tophj@linux.vnet.ibm.com>
2017-05-15 18:34:41 -04:00
Michael Crosby
270a33b666 Add OPOST back to !cgo build for pkg/term
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-05-09 16:36:17 -07:00
Kenfe-Mickaël Laventure
7238cca42c Merge pull request #33007 from crosbymichael/containerd-rc5
Update moby to containerd and runc 1.0 final rc
2017-05-08 09:23:07 -07:00
Michael Crosby
005506d36c Update moby to runc and oci 1.0 runtime final rc
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2017-05-05 13:45:45 -07:00
Tibor Vass
71e9f5c520 Prevent ppc64le to build pkg/term without cgo
Signed-off-by: Tibor Vass <tibor@docker.com>
2017-05-05 12:14:30 -07:00
Aaron.L.Xu
40af569164 fix typo
fix typo I found AMAP in integration-cli/*

fix typo mentioned by Allencloud

Signed-off-by: Aaron.L.Xu <likexu@harmonycloud.cn>
2017-01-19 15:52:28 +08:00
John Howard
e5900ee9bf Windows: Fix crash in docker system prune
Signed-off-by: John Howard <jhoward@microsoft.com>
2016-12-09 14:23:25 -08:00
yupeng
fc11efa2db error strings should not be capitalized or end with punctuation
Signed-off-by: yupeng <yu.peng36@zte.com.cn>
2016-11-22 14:53:11 +08:00
Josh Wilson
c0a5772668 Force input stream ANSI emulation for ConsoleZ
This performs a similar check to the `"ConEmuANSI"` check that was recently
added to enable arrow keys navigation in docker container terminals.

Signed-off-by: Josh Wilson <josh.wilson@fivestars.com>
2016-10-05 12:42:48 -07:00
Brian Goff
28d18b8205 Merge pull request #25578 from rwilliams/conemu
Force input stream ANSI emulation for ConEmu.
2016-09-08 11:12:33 -04:00