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:
KubeSphere CI Bot
2024-09-06 11:05:52 +08:00
committed by GitHub
parent b5015ec7b9
commit 447a51f08b
8557 changed files with 546695 additions and 1146174 deletions

View File

@@ -18,7 +18,11 @@ package printers
import (
"io"
"os"
"runtime"
"strings"
"github.com/moby/term"
)
// terminalEscaper replaces ANSI escape sequences and other terminal special
@@ -37,3 +41,35 @@ func WriteEscaped(writer io.Writer, output string) error {
func EscapeTerminal(in string) string {
return terminalEscaper.Replace(in)
}
// IsTerminal returns whether the passed object is a terminal or not
func IsTerminal(i interface{}) bool {
_, terminal := term.GetFdInfo(i)
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
}