mirror of
https://github.com/containers/podman.git
synced 2025-10-13 09:15:20 +08:00
move golang.org/x/crypto/ssh/terminal to golang.org/x/term
golang.org/x/crypto/ssh/terminal is deprecated. The package was moved to golang.org/x/term. golang.org/x/crypto/ssh/terminal was already just calling golang.org/x/term itslef so there are no functional changes. Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
@ -11,7 +11,7 @@ import (
|
||||
"github.com/containers/podman/v4/pkg/domain/entities"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cobra"
|
||||
"golang.org/x/crypto/ssh/terminal"
|
||||
"golang.org/x/term"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -69,7 +69,7 @@ func init() {
|
||||
func export(cmd *cobra.Command, args []string) error {
|
||||
if len(exportOpts.Output) == 0 {
|
||||
file := os.Stdout
|
||||
if terminal.IsTerminal(int(file.Fd())) {
|
||||
if term.IsTerminal(int(file.Fd())) {
|
||||
return errors.Errorf("refusing to export to terminal. Use -o flag or redirect")
|
||||
}
|
||||
exportOpts.Output = "/dev/stdout"
|
||||
|
@ -18,7 +18,7 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cobra"
|
||||
"golang.org/x/crypto/ssh/terminal"
|
||||
"golang.org/x/term"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -112,7 +112,7 @@ func run(cmd *cobra.Command, args []string) error {
|
||||
var err error
|
||||
|
||||
// TODO: Breaking change should be made fatal in next major Release
|
||||
if cliVals.TTY && cliVals.Interactive && !terminal.IsTerminal(int(os.Stdin.Fd())) {
|
||||
if cliVals.TTY && cliVals.Interactive && !term.IsTerminal(int(os.Stdin.Fd())) {
|
||||
logrus.Warnf("The input device is not a TTY. The --tty and --interactive flags might not work properly")
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,7 @@ import (
|
||||
"github.com/containers/podman/v4/pkg/util"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cobra"
|
||||
"golang.org/x/crypto/ssh/terminal"
|
||||
"golang.org/x/term"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -90,7 +90,7 @@ func load(cmd *cobra.Command, args []string) error {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
if terminal.IsTerminal(int(os.Stdin.Fd())) {
|
||||
if term.IsTerminal(int(os.Stdin.Fd())) {
|
||||
return errors.Errorf("cannot read from terminal. Use command-line redirection or the --input flag.")
|
||||
}
|
||||
outFile, err := ioutil.TempFile(util.Tmpdir(), "podman")
|
||||
|
@ -14,7 +14,7 @@ import (
|
||||
"github.com/containers/podman/v4/pkg/util"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cobra"
|
||||
"golang.org/x/crypto/ssh/terminal"
|
||||
"golang.org/x/term"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -109,7 +109,7 @@ func save(cmd *cobra.Command, args []string) (finalErr error) {
|
||||
if len(saveOpts.Output) == 0 {
|
||||
saveOpts.Quiet = true
|
||||
fi := os.Stdout
|
||||
if terminal.IsTerminal(int(fi.Fd())) {
|
||||
if term.IsTerminal(int(fi.Fd())) {
|
||||
return errors.Errorf("refusing to save to terminal. Use -o flag or redirect")
|
||||
}
|
||||
pipePath, cleanup, err := setupPipe()
|
||||
|
1
go.mod
1
go.mod
@ -68,6 +68,7 @@ require (
|
||||
golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
|
||||
golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211
|
||||
golang.org/x/text v0.3.7
|
||||
google.golang.org/protobuf v1.28.0
|
||||
gopkg.in/inf.v0 v0.9.1
|
||||
|
@ -20,7 +20,7 @@ import (
|
||||
"github.com/moby/term"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
"golang.org/x/crypto/ssh/terminal"
|
||||
terminal "golang.org/x/term"
|
||||
)
|
||||
|
||||
// The CloseWriter interface is used to determine whether we can do a one-sided
|
||||
|
@ -9,11 +9,11 @@ import (
|
||||
"os/signal"
|
||||
|
||||
sig "github.com/containers/podman/v4/pkg/signal"
|
||||
"golang.org/x/crypto/ssh/terminal"
|
||||
"golang.org/x/term"
|
||||
)
|
||||
|
||||
func makeRawTerm(stdin *os.File) (*terminal.State, error) {
|
||||
return terminal.MakeRaw(int(stdin.Fd()))
|
||||
func makeRawTerm(stdin *os.File) (*term.State, error) {
|
||||
return term.MakeRaw(int(stdin.Fd()))
|
||||
}
|
||||
|
||||
func notifyWinChange(ctx context.Context, winChange chan os.Signal, stdin *os.File, stdout *os.File) {
|
||||
@ -21,5 +21,5 @@ func notifyWinChange(ctx context.Context, winChange chan os.Signal, stdin *os.Fi
|
||||
}
|
||||
|
||||
func getTermSize(stdin *os.File, stdout *os.File) (width, height int, err error) {
|
||||
return terminal.GetSize(int(stdin.Fd()))
|
||||
return term.GetSize(int(stdin.Fd()))
|
||||
}
|
||||
|
@ -6,12 +6,12 @@ import (
|
||||
"time"
|
||||
|
||||
sig "github.com/containers/podman/v4/pkg/signal"
|
||||
"golang.org/x/crypto/ssh/terminal"
|
||||
"golang.org/x/sys/windows"
|
||||
"golang.org/x/term"
|
||||
)
|
||||
|
||||
func makeRawTerm(stdin *os.File) (*terminal.State, error) {
|
||||
state, err := terminal.MakeRaw(int(stdin.Fd()))
|
||||
func makeRawTerm(stdin *os.File) (*term.State, error) {
|
||||
state, err := term.MakeRaw(int(stdin.Fd()))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -51,7 +51,7 @@ func notifyWinChange(ctx context.Context, winChange chan os.Signal, stdin *os.Fi
|
||||
break
|
||||
}
|
||||
|
||||
w, h, err := terminal.GetSize(int(stdout.Fd()))
|
||||
w, h, err := term.GetSize(int(stdout.Fd()))
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
@ -65,5 +65,5 @@ func notifyWinChange(ctx context.Context, winChange chan os.Signal, stdin *os.Fi
|
||||
}
|
||||
|
||||
func getTermSize(stdin *os.File, stdout *os.File) (width, height int, err error) {
|
||||
return terminal.GetSize(int(stdout.Fd()))
|
||||
return term.GetSize(int(stdout.Fd()))
|
||||
}
|
||||
|
@ -10,13 +10,13 @@ import (
|
||||
"github.com/containers/podman/v4/libpod/define"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
"golang.org/x/crypto/ssh/terminal"
|
||||
"golang.org/x/term"
|
||||
)
|
||||
|
||||
// ExecAttachCtr execs and attaches to a container
|
||||
func ExecAttachCtr(ctx context.Context, ctr *libpod.Container, execConfig *libpod.ExecConfig, streams *define.AttachStreams) (int, error) {
|
||||
var resize chan define.TerminalSize
|
||||
haveTerminal := terminal.IsTerminal(int(os.Stdin.Fd()))
|
||||
haveTerminal := term.IsTerminal(int(os.Stdin.Fd()))
|
||||
|
||||
// Check if we are attached to a terminal. If we are, generate resize
|
||||
// events, and set the terminal to raw mode
|
||||
@ -42,7 +42,7 @@ func ExecAttachCtr(ctx context.Context, ctr *libpod.Container, execConfig *libpo
|
||||
func StartAttachCtr(ctx context.Context, ctr *libpod.Container, stdout, stderr, stdin *os.File, detachKeys string, sigProxy bool, startContainer bool) error { //nolint: interfacer
|
||||
resize := make(chan define.TerminalSize)
|
||||
|
||||
haveTerminal := terminal.IsTerminal(int(os.Stdin.Fd()))
|
||||
haveTerminal := term.IsTerminal(int(os.Stdin.Fd()))
|
||||
|
||||
// Check if we are attached to a terminal. If we are, generate resize
|
||||
// events, and set the terminal to raw mode
|
||||
|
@ -14,7 +14,7 @@ import (
|
||||
"github.com/sirupsen/logrus"
|
||||
"golang.org/x/crypto/ssh"
|
||||
"golang.org/x/crypto/ssh/knownhosts"
|
||||
"golang.org/x/crypto/ssh/terminal"
|
||||
"golang.org/x/term"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -29,9 +29,9 @@ var (
|
||||
// Additionally, all input after `<secret>/n` is queued to podman command.
|
||||
func ReadPassword(prompt string) (pw []byte, err error) {
|
||||
fd := int(os.Stdin.Fd())
|
||||
if terminal.IsTerminal(fd) {
|
||||
if term.IsTerminal(fd) {
|
||||
fmt.Fprint(os.Stderr, prompt)
|
||||
pw, err = terminal.ReadPassword(fd)
|
||||
pw, err = term.ReadPassword(fd)
|
||||
fmt.Fprintln(os.Stderr)
|
||||
return
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ import (
|
||||
"github.com/opencontainers/runtime-spec/specs-go"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
"golang.org/x/crypto/ssh/terminal"
|
||||
"golang.org/x/term"
|
||||
)
|
||||
|
||||
var containerConfig *config.Config
|
||||
@ -65,7 +65,7 @@ func ParseRegistryCreds(creds string) (*types.DockerAuthConfig, error) {
|
||||
}
|
||||
if password == "" {
|
||||
fmt.Print("Password: ")
|
||||
termPassword, err := terminal.ReadPassword(0)
|
||||
termPassword, err := term.ReadPassword(0)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "could not read password from terminal")
|
||||
}
|
||||
|
76
vendor/golang.org/x/crypto/ssh/terminal/terminal.go
generated
vendored
76
vendor/golang.org/x/crypto/ssh/terminal/terminal.go
generated
vendored
@ -1,76 +0,0 @@
|
||||
// Copyright 2011 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Package terminal provides support functions for dealing with terminals, as
|
||||
// commonly found on UNIX systems.
|
||||
//
|
||||
// Deprecated: this package moved to golang.org/x/term.
|
||||
package terminal
|
||||
|
||||
import (
|
||||
"io"
|
||||
|
||||
"golang.org/x/term"
|
||||
)
|
||||
|
||||
// EscapeCodes contains escape sequences that can be written to the terminal in
|
||||
// order to achieve different styles of text.
|
||||
type EscapeCodes = term.EscapeCodes
|
||||
|
||||
// Terminal contains the state for running a VT100 terminal that is capable of
|
||||
// reading lines of input.
|
||||
type Terminal = term.Terminal
|
||||
|
||||
// NewTerminal runs a VT100 terminal on the given ReadWriter. If the ReadWriter is
|
||||
// a local terminal, that terminal must first have been put into raw mode.
|
||||
// prompt is a string that is written at the start of each input line (i.e.
|
||||
// "> ").
|
||||
func NewTerminal(c io.ReadWriter, prompt string) *Terminal {
|
||||
return term.NewTerminal(c, prompt)
|
||||
}
|
||||
|
||||
// ErrPasteIndicator may be returned from ReadLine as the error, in addition
|
||||
// to valid line data. It indicates that bracketed paste mode is enabled and
|
||||
// that the returned line consists only of pasted data. Programs may wish to
|
||||
// interpret pasted data more literally than typed data.
|
||||
var ErrPasteIndicator = term.ErrPasteIndicator
|
||||
|
||||
// State contains the state of a terminal.
|
||||
type State = term.State
|
||||
|
||||
// IsTerminal returns whether the given file descriptor is a terminal.
|
||||
func IsTerminal(fd int) bool {
|
||||
return term.IsTerminal(fd)
|
||||
}
|
||||
|
||||
// ReadPassword reads a line of input from a terminal without local echo. This
|
||||
// is commonly used for inputting passwords and other sensitive data. The slice
|
||||
// returned does not include the \n.
|
||||
func ReadPassword(fd int) ([]byte, error) {
|
||||
return term.ReadPassword(fd)
|
||||
}
|
||||
|
||||
// MakeRaw puts the terminal connected to the given file descriptor into raw
|
||||
// mode and returns the previous state of the terminal so that it can be
|
||||
// restored.
|
||||
func MakeRaw(fd int) (*State, error) {
|
||||
return term.MakeRaw(fd)
|
||||
}
|
||||
|
||||
// Restore restores the terminal connected to the given file descriptor to a
|
||||
// previous state.
|
||||
func Restore(fd int, oldState *State) error {
|
||||
return term.Restore(fd, oldState)
|
||||
}
|
||||
|
||||
// GetState returns the current state of a terminal which may be useful to
|
||||
// restore the terminal after a signal.
|
||||
func GetState(fd int) (*State, error) {
|
||||
return term.GetState(fd)
|
||||
}
|
||||
|
||||
// GetSize returns the dimensions of the given terminal.
|
||||
func GetSize(fd int) (width, height int, err error) {
|
||||
return term.GetSize(fd)
|
||||
}
|
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
@ -718,7 +718,6 @@ golang.org/x/crypto/ssh
|
||||
golang.org/x/crypto/ssh/agent
|
||||
golang.org/x/crypto/ssh/internal/bcrypt_pbkdf
|
||||
golang.org/x/crypto/ssh/knownhosts
|
||||
golang.org/x/crypto/ssh/terminal
|
||||
# golang.org/x/net v0.0.0-20220225172249-27dd8689420f
|
||||
golang.org/x/net/context
|
||||
golang.org/x/net/html
|
||||
@ -744,6 +743,7 @@ golang.org/x/sys/unix
|
||||
golang.org/x/sys/windows
|
||||
golang.org/x/sys/windows/registry
|
||||
# golang.org/x/term v0.0.0-20210927222741-03fcf44c2211
|
||||
## explicit
|
||||
golang.org/x/term
|
||||
# golang.org/x/text v0.3.7
|
||||
## explicit
|
||||
|
Reference in New Issue
Block a user