|
|
|
@ -89,8 +89,8 @@ type EnvSettings struct {
|
|
|
|
|
BurstLimit int
|
|
|
|
|
// QPS is queries per second which may be used to avoid throttling.
|
|
|
|
|
QPS float32
|
|
|
|
|
// NoColor disables colorized output
|
|
|
|
|
NoColor bool
|
|
|
|
|
// ColorMode controls colorized output (never, auto, always)
|
|
|
|
|
ColorMode string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func New() *EnvSettings {
|
|
|
|
@ -111,7 +111,7 @@ func New() *EnvSettings {
|
|
|
|
|
RepositoryCache: envOr("HELM_REPOSITORY_CACHE", helmpath.CachePath("repository")),
|
|
|
|
|
BurstLimit: envIntOr("HELM_BURST_LIMIT", defaultBurstLimit),
|
|
|
|
|
QPS: envFloat32Or("HELM_QPS", defaultQPS),
|
|
|
|
|
NoColor: envBoolOr("NO_COLOR", false),
|
|
|
|
|
ColorMode: envColorMode(),
|
|
|
|
|
}
|
|
|
|
|
env.Debug, _ = strconv.ParseBool(os.Getenv("HELM_DEBUG"))
|
|
|
|
|
|
|
|
|
@ -163,7 +163,8 @@ func (s *EnvSettings) AddFlags(fs *pflag.FlagSet) {
|
|
|
|
|
fs.StringVar(&s.RepositoryCache, "repository-cache", s.RepositoryCache, "path to the directory containing cached repository indexes")
|
|
|
|
|
fs.IntVar(&s.BurstLimit, "burst-limit", s.BurstLimit, "client-side default throttling limit")
|
|
|
|
|
fs.Float32Var(&s.QPS, "qps", s.QPS, "queries per second used when communicating with the Kubernetes API, not including bursting")
|
|
|
|
|
fs.BoolVar(&s.NoColor, "no-color", s.NoColor, "disable colorized output")
|
|
|
|
|
fs.StringVar(&s.ColorMode, "color", s.ColorMode, "use colored output (never, auto, always)")
|
|
|
|
|
fs.StringVar(&s.ColorMode, "colour", s.ColorMode, "use colored output (never, auto, always)")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func envOr(name, def string) string {
|
|
|
|
@ -217,6 +218,23 @@ func envCSV(name string) (ls []string) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func envColorMode() string {
|
|
|
|
|
// Check NO_COLOR environment variable first (standard)
|
|
|
|
|
if v, ok := os.LookupEnv("NO_COLOR"); ok && v != "" {
|
|
|
|
|
return "never"
|
|
|
|
|
}
|
|
|
|
|
// Check HELM_COLOR environment variable
|
|
|
|
|
if v, ok := os.LookupEnv("HELM_COLOR"); ok {
|
|
|
|
|
v = strings.ToLower(v)
|
|
|
|
|
switch v {
|
|
|
|
|
case "never", "auto", "always":
|
|
|
|
|
return v
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Default to auto
|
|
|
|
|
return "auto"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *EnvSettings) EnvVars() map[string]string {
|
|
|
|
|
envvars := map[string]string{
|
|
|
|
|
"HELM_BIN": os.Args[0],
|
|
|
|
@ -269,3 +287,25 @@ func (s *EnvSettings) SetNamespace(namespace string) {
|
|
|
|
|
func (s *EnvSettings) RESTClientGetter() genericclioptions.RESTClientGetter {
|
|
|
|
|
return s.config
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ColorEnabled returns true if color output should be enabled based on the ColorMode setting
|
|
|
|
|
func (s *EnvSettings) ColorEnabled() bool {
|
|
|
|
|
switch s.ColorMode {
|
|
|
|
|
case "never":
|
|
|
|
|
return false
|
|
|
|
|
case "always":
|
|
|
|
|
return true
|
|
|
|
|
case "auto":
|
|
|
|
|
// Auto mode is handled by fatih/color's built-in terminal detection
|
|
|
|
|
// We just need to not override it
|
|
|
|
|
return true
|
|
|
|
|
default:
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ShouldDisableColor returns true if color output should be disabled
|
|
|
|
|
// This is the inverse of ColorEnabled for backward compatibility with noColor parameters
|
|
|
|
|
func (s *EnvSettings) ShouldDisableColor() bool {
|
|
|
|
|
return s.ColorMode == "never"
|
|
|
|
|
}
|
|
|
|
|