Skip to content

Commit 7f04990

Browse files
committed
Move to creack pty
Signed-off-by: apostasie <[email protected]>
1 parent 0020c91 commit 7f04990

File tree

9 files changed

+31
-149
lines changed

9 files changed

+31
-149
lines changed

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ require (
8181
github.com/containerd/plugin v1.0.0 // indirect
8282
github.com/containerd/ttrpc v1.2.7 // indirect
8383
github.com/containers/ocicrypt v1.2.1 // indirect
84+
github.com/creack/pty v1.1.24 // indirect
8485
github.com/djherbis/times v1.6.0 // indirect
8586
github.com/docker/docker-credential-helpers v0.8.2 // indirect
8687
github.com/felixge/httpsnoop v1.0.4 // indirect

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,8 @@ github.com/coreos/go-iptables v0.8.0/go.mod h1:Qe8Bv2Xik5FyTXwgIbLAnv2sWSBmvWdFE
7676
github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs=
7777
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
7878
github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g=
79-
github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY=
80-
github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
79+
github.com/creack/pty v1.1.24 h1:bJrF4RRfyJnbTJqzRLHzcGaZK1NeM5kTC9jGgovnR1s=
80+
github.com/creack/pty v1.1.24/go.mod h1:08sCNb52WyoAwi2QDyzUCTgcvVFhUzewun7wtTfvcwE=
8181
github.com/cyphar/filepath-securejoin v0.4.1 h1:JyxxyPEaktOD+GAnqIqTf9A8tHyAG22rowi7HkoSU1s=
8282
github.com/cyphar/filepath-securejoin v0.4.1/go.mod h1:Sdj7gXlvMcPZsbhwhQ33GguGLDGQL7h7bg04C/+u9jI=
8383
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=

mod/tigron/go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module github.com/containerd/nerdctl/mod/tigron
33
go 1.23
44

55
require (
6+
github.com/creack/pty v1.1.24
67
golang.org/x/sync v0.11.0
78
golang.org/x/term v0.29.0
89
gotest.tools/v3 v3.5.2

mod/tigron/go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
github.com/creack/pty v1.1.24 h1:bJrF4RRfyJnbTJqzRLHzcGaZK1NeM5kTC9jGgovnR1s=
2+
github.com/creack/pty v1.1.24/go.mod h1:08sCNb52WyoAwi2QDyzUCTgcvVFhUzewun7wtTfvcwE=
13
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
24
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
35
golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w=

mod/tigron/test/internal/pty/pty.go

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,33 @@
1414
limitations under the License.
1515
*/
1616

17+
// Package pty.
18+
// Note that creack is MIT licensed, making it better to depend on it rather than using derived code here.
19+
// Underlying creack implementation is OK though they have more (unnecessary to us) features and do not follow the
20+
// same coding standards.
1721
package pty
1822

19-
import "errors"
23+
import (
24+
"errors"
25+
"os"
26+
27+
creack "github.com/creack/pty"
28+
)
2029

2130
var (
22-
ErrPTYFailure = errors.New("pty failure")
23-
ErrPTYUnsupportedPlatform = errors.New("pty not supported on this platform")
31+
ErrFailure = errors.New("pty failure")
32+
ErrUnsupportedPlatform = errors.New("pty not supported on this platform")
2433
)
34+
35+
func Open() (*os.File, *os.File, error) {
36+
pty, tty, err := creack.Open()
37+
if err != nil {
38+
if errors.Is(err, creack.ErrUnsupported) {
39+
err = errors.Join(ErrUnsupportedPlatform, err)
40+
} else {
41+
err = errors.Join(ErrFailure, err)
42+
}
43+
}
44+
45+
return pty, tty, err
46+
}

mod/tigron/test/internal/pty/pty_darwin.go

Lines changed: 0 additions & 25 deletions
This file was deleted.

mod/tigron/test/internal/pty/pty_freebsd.go

Lines changed: 0 additions & 25 deletions
This file was deleted.

mod/tigron/test/internal/pty/pty_linux.go

Lines changed: 0 additions & 69 deletions
This file was deleted.

mod/tigron/test/internal/pty/pty_windows.go

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)