2
vendor/k8s.io/kubectl/pkg/util/term/resize.go
generated
vendored
2
vendor/k8s.io/kubectl/pkg/util/term/resize.go
generated
vendored
@@ -19,7 +19,7 @@ package term
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/docker/docker/pkg/term"
|
||||
"github.com/moby/term"
|
||||
"k8s.io/apimachinery/pkg/util/runtime"
|
||||
"k8s.io/client-go/tools/remotecommand"
|
||||
)
|
||||
|
||||
29
vendor/k8s.io/kubectl/pkg/util/term/term.go
generated
vendored
29
vendor/k8s.io/kubectl/pkg/util/term/term.go
generated
vendored
@@ -19,8 +19,9 @@ package term
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
"runtime"
|
||||
|
||||
"github.com/docker/docker/pkg/term"
|
||||
"github.com/moby/term"
|
||||
|
||||
"k8s.io/kubectl/pkg/util/interrupt"
|
||||
)
|
||||
@@ -70,6 +71,32 @@ func IsTerminal(i interface{}) bool {
|
||||
return terminal
|
||||
}
|
||||
|
||||
// AllowsColorOutput returns true if the specified writer is a terminal and
|
||||
// the process environment indicates color output is supported and desired.
|
||||
func AllowsColorOutput(w io.Writer) bool {
|
||||
if !IsTerminal(w) {
|
||||
return false
|
||||
}
|
||||
|
||||
// https://en.wikipedia.org/wiki/Computer_terminal#Dumb_terminals
|
||||
if os.Getenv("TERM") == "dumb" {
|
||||
return false
|
||||
}
|
||||
|
||||
// https://no-color.org/
|
||||
if _, nocolor := os.LookupEnv("NO_COLOR"); nocolor {
|
||||
return false
|
||||
}
|
||||
|
||||
// On Windows WT_SESSION is set by the modern terminal component.
|
||||
// Older terminals have poor support for UTF-8, VT escape codes, etc.
|
||||
if runtime.GOOS == "windows" && os.Getenv("WT_SESSION") == "" {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
// Safe invokes the provided function and will attempt to ensure that when the
|
||||
// function returns (or a termination signal is sent) that the terminal state
|
||||
// is reset to the condition it was in prior to the function being invoked. If
|
||||
|
||||
2
vendor/k8s.io/kubectl/pkg/util/term/term_writer.go
generated
vendored
2
vendor/k8s.io/kubectl/pkg/util/term/term_writer.go
generated
vendored
@@ -20,8 +20,8 @@ import (
|
||||
"io"
|
||||
"os"
|
||||
|
||||
"github.com/docker/docker/pkg/term"
|
||||
wordwrap "github.com/mitchellh/go-wordwrap"
|
||||
"github.com/moby/term"
|
||||
)
|
||||
|
||||
type wordWrapWriter struct {
|
||||
|
||||
Reference in New Issue
Block a user