feat: kubesphere 4.0 (#6115)
* feat: kubesphere 4.0 Signed-off-by: ci-bot <ci-bot@kubesphere.io> * feat: kubesphere 4.0 Signed-off-by: ci-bot <ci-bot@kubesphere.io> --------- Signed-off-by: ci-bot <ci-bot@kubesphere.io> Co-authored-by: ks-ci-bot <ks-ci-bot@example.com> Co-authored-by: joyceliu <joyceliu@yunify.com>
This commit is contained in:
committed by
GitHub
parent
b5015ec7b9
commit
447a51f08b
40
vendor/k8s.io/kubectl/pkg/util/term/term.go
generated
vendored
40
vendor/k8s.io/kubectl/pkg/util/term/term.go
generated
vendored
@@ -19,7 +19,8 @@ package term
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
"runtime"
|
||||
|
||||
"k8s.io/cli-runtime/pkg/printers"
|
||||
|
||||
"github.com/moby/term"
|
||||
|
||||
@@ -56,46 +57,23 @@ type TTY struct {
|
||||
// IsTerminalIn returns true if t.In is a terminal. Does not check /dev/tty
|
||||
// even if TryDev is set.
|
||||
func (t TTY) IsTerminalIn() bool {
|
||||
return IsTerminal(t.In)
|
||||
return printers.IsTerminal(t.In)
|
||||
}
|
||||
|
||||
// IsTerminalOut returns true if t.Out is a terminal. Does not check /dev/tty
|
||||
// even if TryDev is set.
|
||||
func (t TTY) IsTerminalOut() bool {
|
||||
return IsTerminal(t.Out)
|
||||
return printers.IsTerminal(t.Out)
|
||||
}
|
||||
|
||||
// IsTerminal returns whether the passed object is a terminal or not
|
||||
func IsTerminal(i interface{}) bool {
|
||||
_, terminal := term.GetFdInfo(i)
|
||||
return terminal
|
||||
}
|
||||
// IsTerminal returns whether the passed object is a terminal or not.
|
||||
// Deprecated: use printers.IsTerminal instead.
|
||||
var IsTerminal = printers.IsTerminal
|
||||
|
||||
// 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
|
||||
}
|
||||
// Deprecated: use printers.AllowsColorOutput instead.
|
||||
var AllowsColorOutput = printers.AllowsColorOutput
|
||||
|
||||
// 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
|
||||
|
||||
Reference in New Issue
Block a user