MCPcopy Create free account
hub / github.com/Azure/ARO-HCP / CreateCommand

Method CreateCommand

tooling/hcpctl/pkg/shell/types.go:90–118  ·  view source on GitHub ↗
(ctx context.Context, config *Config, kubeconfigPath string)

Source from the content-addressed store, hash-verified

88}
89
90func (u *UnixShell) CreateCommand(ctx context.Context, config *Config, kubeconfigPath string) *exec.Cmd {
91 cmd := exec.CommandContext(ctx, u.executable)
92
93 // setup env
94 env := cmd.Environ()
95 env = setEnvironmentVariable(env, "KUBECONFIG", kubeconfigPath)
96
97 // set custom prompt with color based on privilege level
98 var promptColor string
99 if config.Privileged {
100 promptColor = "\\[\\033[1;31m\\]" // red
101 } else {
102 promptColor = "\\[\\033[1;34m\\]" // blue
103 }
104 prompt := fmt.Sprintf("%s%s\\[\\033[0m\\] \\u@\\h:\\w$ ", promptColor, config.PromptInfo)
105 env = setEnvironmentVariable(env, "PS1", prompt)
106
107 // Suppress macOS bash deprecation warning that appears when bash is spawned
108 // on systems where zsh is the default shell. This prevents the noisy message:
109 // "The default interactive shell is now zsh. To update your account to use zsh..."
110 env = setEnvironmentVariable(env, "BASH_SILENCE_DEPRECATION_WARNING", "1")
111
112 cmd.Env = env
113 cmd.Stdin = os.Stdin
114 cmd.Stdout = os.Stdout
115 cmd.Stderr = os.Stderr
116
117 return cmd
118}

Callers

nothing calls this directly

Calls 1

setEnvironmentVariableFunction · 0.85

Tested by

no test coverage detected