Skip to content

Commit

Permalink
Move to golang.org/x/term from golang.org/x/crypto/ssh/terminal
Browse files Browse the repository at this point in the history
  • Loading branch information
mstoykov committed Oct 5, 2021
1 parent 5c25ef3 commit 67a07dd
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 87 deletions.
4 changes: 2 additions & 2 deletions cmd/login_cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
"github.com/sirupsen/logrus"
"github.com/spf13/afero"
"github.com/spf13/cobra"
"golang.org/x/crypto/ssh/terminal"
"golang.org/x/term"
"gopkg.in/guregu/null.v3"

"go.k6.io/k6/cloudapi"
Expand Down Expand Up @@ -108,7 +108,7 @@ This will set the default token used when just "k6 run -o cloud" is passed.`,
},
},
}
if !terminal.IsTerminal(int(syscall.Stdin)) { // nolint: unconvert
if !term.IsTerminal(int(syscall.Stdin)) { // nolint: unconvert
logger.Warn("Stdin is not a terminal, falling back to plain text input")
}
vals, err := form.Run(os.Stdin, stdout)
Expand Down
4 changes: 2 additions & 2 deletions cmd/login_influxdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
"github.com/sirupsen/logrus"
"github.com/spf13/afero"
"github.com/spf13/cobra"
"golang.org/x/crypto/ssh/terminal"
"golang.org/x/term"

"go.k6.io/k6/lib/types"
"go.k6.io/k6/output/influxdb"
Expand Down Expand Up @@ -93,7 +93,7 @@ This will set the default server used when just "-o influxdb" is passed.`,
},
},
}
if !terminal.IsTerminal(int(syscall.Stdin)) { // nolint: unconvert
if !term.IsTerminal(int(syscall.Stdin)) { // nolint: unconvert
logger.Warn("Stdin is not a terminal, falling back to plain text input")
}
vals, err := form.Run(os.Stdin, stdout)
Expand Down
9 changes: 5 additions & 4 deletions cmd/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ import (

"github.com/fatih/color"
"github.com/sirupsen/logrus"
"golang.org/x/crypto/ssh/terminal"
"golang.org/x/term"

"gopkg.in/yaml.v3"

"go.k6.io/k6/lib"
Expand Down Expand Up @@ -282,7 +283,7 @@ func showProgress(
var errTermGetSize bool
termWidth := defaultTermWidth
if stdoutTTY {
tw, _, err := terminal.GetSize(int(os.Stdout.Fd()))
tw, _, err := term.GetSize(int(os.Stdout.Fd()))
if !(tw > 0) || err != nil {
errTermGetSize = true
logger.WithError(err).Warn("error getting terminal size")
Expand Down Expand Up @@ -370,15 +371,15 @@ func showProgress(
case <-winch:
if stdoutTTY && !errTermGetSize {
// More responsive progress bar resizing on platforms with SIGWINCH (*nix)
tw, _, err := terminal.GetSize(fd)
tw, _, err := term.GetSize(fd)
if tw > 0 && err == nil {
termWidth = tw
}
}
case <-ticker.C:
// Default ticker-based progress bar resizing
if stdoutTTY && !errTermGetSize && winch == nil {
tw, _, err := terminal.GetSize(fd)
tw, _, err := term.GetSize(fd)
if tw > 0 && err == nil {
termWidth = tw
}
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ require (
golang.org/x/crypto v0.0.0-20210503195802-e9a32991a82e
golang.org/x/net v0.0.0-20210901185426-6d2eada6345e
golang.org/x/sys v0.0.0-20210511113859-b0526f3d8744 // indirect
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac
google.golang.org/genproto v0.0.0-20200903010400-9bfcb5116336 // indirect
google.golang.org/grpc v1.41.0
Expand Down
4 changes: 2 additions & 2 deletions ui/form_fields.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"os"
"strings"

"golang.org/x/crypto/ssh/terminal"
"golang.org/x/term"
)

// Verify that the fields implement the interface
Expand Down Expand Up @@ -123,7 +123,7 @@ func (f PasswordField) GetContents(r io.Reader) (string, error) {
if !ok {
return "", errors.New("cannot read password from the supplied terminal")
}
password, err := terminal.ReadPassword(int(stdin.Fd()))
password, err := term.ReadPassword(int(stdin.Fd()))
if err != nil {
// Possibly running on Cygwin/mintty which doesn't emulate
// pseudo terminals properly, so fallback to plain text input.
Expand Down
76 changes: 0 additions & 76 deletions vendor/golang.org/x/crypto/ssh/terminal/terminal.go

This file was deleted.

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ github.com/tidwall/pretty
golang.org/x/crypto/md4
golang.org/x/crypto/ocsp
golang.org/x/crypto/ripemd160
golang.org/x/crypto/ssh/terminal
# golang.org/x/net v0.0.0-20210901185426-6d2eada6345e
## explicit
golang.org/x/net/html
Expand All @@ -178,6 +177,7 @@ golang.org/x/sys/plan9
golang.org/x/sys/unix
golang.org/x/sys/windows
# golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1
## explicit
golang.org/x/term
# golang.org/x/text v0.3.6
golang.org/x/text/cases
Expand Down

0 comments on commit 67a07dd

Please sign in to comment.