pass profilename for testability
parent
4b9d15a34c
commit
435010a3fc
|
@ -128,9 +128,9 @@ type NoProxyGetter interface {
|
|||
// EnvNoProxyGetter gets the no_proxy variable, using environment
|
||||
type EnvNoProxyGetter struct{}
|
||||
|
||||
func generateUsageHint(userShell string) string {
|
||||
func generateUsageHint(profile string, userShell string) string {
|
||||
const usgPlz = "Please run command bellow to point your shell to minikube's docker-daemon :"
|
||||
var usgCmd = fmt.Sprintf("minikube -p %s docker-env", viper.GetString(config.MachineProfile))
|
||||
var usgCmd = fmt.Sprintf("minikube -p %s docker-env", profile)
|
||||
var usageHintMap = map[string]string{
|
||||
"bash": fmt.Sprintf(`
|
||||
# %s
|
||||
|
@ -178,7 +178,7 @@ func shellCfgSet(api libmachine.API) (*ShellConfig, error) {
|
|||
DockerHost: envMap[constants.DockerHostEnv],
|
||||
DockerTLSVerify: envMap[constants.DockerTLSVerifyEnv],
|
||||
MinikubeDockerdProfile: envMap[constants.MinikubeActiveDockerdEnv],
|
||||
UsageHint: generateUsageHint(userShell),
|
||||
UsageHint: generateUsageHint(viper.GetString(config.MachineProfile), userShell),
|
||||
}
|
||||
|
||||
if noProxy {
|
||||
|
@ -247,7 +247,7 @@ func shellCfgUnset() (*ShellConfig, error) {
|
|||
}
|
||||
|
||||
shellCfg := &ShellConfig{
|
||||
UsageHint: generateUsageHint(userShell),
|
||||
UsageHint: generateUsageHint(viper.GetString(config.MachineProfile), userShell),
|
||||
}
|
||||
|
||||
if noProxy {
|
||||
|
|
|
@ -62,7 +62,7 @@ func newShellCfg(shell, prefix, suffix, delim string) *ShellConfig {
|
|||
DockerCertPath: localpath.MakeMiniPath("certs"),
|
||||
DockerTLSVerify: "1",
|
||||
DockerHost: "tcp://127.0.0.1:2376",
|
||||
UsageHint: generateUsageHint(shell),
|
||||
UsageHint: generateUsageHint("minikube", shell),
|
||||
Prefix: prefix,
|
||||
Suffix: suffix,
|
||||
Delimiter: delim,
|
||||
|
@ -144,7 +144,7 @@ func TestShellCfgSet(t *testing.T) {
|
|||
DockerCertPath: localpath.MakeMiniPath("certs"),
|
||||
DockerTLSVerify: "1",
|
||||
DockerHost: "tcp://127.0.0.1:2376",
|
||||
UsageHint: usageHintMap["bash"],
|
||||
UsageHint: generateUsageHint("minikube", "bash"),
|
||||
Prefix: bashSetPfx,
|
||||
Suffix: bashSetSfx,
|
||||
Delimiter: bashSetDelim,
|
||||
|
@ -163,7 +163,7 @@ func TestShellCfgSet(t *testing.T) {
|
|||
DockerCertPath: localpath.MakeMiniPath("certs"),
|
||||
DockerTLSVerify: "1",
|
||||
DockerHost: "tcp://127.0.0.1:2376",
|
||||
UsageHint: usageHintMap["bash"],
|
||||
UsageHint: generateUsageHint("minikube", "bash"),
|
||||
Prefix: bashSetPfx,
|
||||
Suffix: bashSetSfx,
|
||||
Delimiter: bashSetDelim,
|
||||
|
@ -182,7 +182,7 @@ func TestShellCfgSet(t *testing.T) {
|
|||
DockerCertPath: localpath.MakeMiniPath("certs"),
|
||||
DockerTLSVerify: "1",
|
||||
DockerHost: "tcp://127.0.0.1:2376",
|
||||
UsageHint: usageHintMap["bash"],
|
||||
UsageHint: generateUsageHint("minikube", "bash"),
|
||||
Prefix: bashSetPfx,
|
||||
Suffix: bashSetSfx,
|
||||
Delimiter: bashSetDelim,
|
||||
|
@ -201,7 +201,7 @@ func TestShellCfgSet(t *testing.T) {
|
|||
DockerCertPath: localpath.MakeMiniPath("certs"),
|
||||
DockerTLSVerify: "1",
|
||||
DockerHost: "tcp://127.0.0.1:2376",
|
||||
UsageHint: usageHintMap["bash"],
|
||||
UsageHint: generateUsageHint("minikube", "bash"),
|
||||
Prefix: bashSetPfx,
|
||||
Suffix: bashSetSfx,
|
||||
Delimiter: bashSetDelim,
|
||||
|
@ -220,7 +220,7 @@ func TestShellCfgSet(t *testing.T) {
|
|||
DockerCertPath: localpath.MakeMiniPath("certs"),
|
||||
DockerTLSVerify: "1",
|
||||
DockerHost: "tcp://127.0.0.1:2376",
|
||||
UsageHint: usageHintMap["bash"],
|
||||
UsageHint: generateUsageHint("minikube", "bash"),
|
||||
Prefix: bashSetPfx,
|
||||
Suffix: bashSetSfx,
|
||||
Delimiter: bashSetDelim,
|
||||
|
@ -254,6 +254,7 @@ func TestShellCfgSet(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestShellCfgUnset(t *testing.T) {
|
||||
|
||||
var tests = []struct {
|
||||
description string
|
||||
shell string
|
||||
|
@ -266,7 +267,7 @@ func TestShellCfgUnset(t *testing.T) {
|
|||
Prefix: bashUnsetPfx,
|
||||
Suffix: bashUnsetSfx,
|
||||
Delimiter: bashUnsetDelim,
|
||||
UsageHint: usageHintMap["bash"],
|
||||
UsageHint: generateUsageHint("minikube", "bash"),
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -276,7 +277,7 @@ func TestShellCfgUnset(t *testing.T) {
|
|||
Prefix: bashUnsetPfx,
|
||||
Suffix: bashUnsetSfx,
|
||||
Delimiter: bashUnsetDelim,
|
||||
UsageHint: usageHintMap["bash"],
|
||||
UsageHint: generateUsageHint("minikube", "bash"),
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -286,7 +287,7 @@ func TestShellCfgUnset(t *testing.T) {
|
|||
Prefix: fishUnsetPfx,
|
||||
Suffix: fishUnsetSfx,
|
||||
Delimiter: fishUnsetDelim,
|
||||
UsageHint: usageHintMap["fish"],
|
||||
UsageHint: generateUsageHint("minikube", "fish"),
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -296,7 +297,7 @@ func TestShellCfgUnset(t *testing.T) {
|
|||
Prefix: psUnsetPfx,
|
||||
Suffix: psUnsetSfx,
|
||||
Delimiter: psUnsetDelim,
|
||||
UsageHint: usageHintMap["powershell"],
|
||||
UsageHint: generateUsageHint("minikube", "powershell"),
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -306,7 +307,7 @@ func TestShellCfgUnset(t *testing.T) {
|
|||
Prefix: cmdUnsetPfx,
|
||||
Suffix: cmdUnsetSfx,
|
||||
Delimiter: cmdUnsetDelim,
|
||||
UsageHint: usageHintMap["cmd"],
|
||||
UsageHint: generateUsageHint("minikube", "cmd"),
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -316,7 +317,7 @@ func TestShellCfgUnset(t *testing.T) {
|
|||
Prefix: emacsUnsetPfx,
|
||||
Suffix: emacsUnsetSfx,
|
||||
Delimiter: emacsUnsetDelim,
|
||||
UsageHint: usageHintMap["emacs"],
|
||||
UsageHint: generateUsageHint("minikube", "emacs"),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ func NewExecRunner() Runner {
|
|||
}
|
||||
|
||||
// RunCmd implements the Command Runner interface to run a exec.Cmd object
|
||||
func (e *execRunner) RunCmd(cmd *exec.Cmd) (*RunResult, error) {
|
||||
func (*execRunner) RunCmd(cmd *exec.Cmd) (*RunResult, error) {
|
||||
rr := &RunResult{Args: cmd.Args}
|
||||
var outb, errb io.Writer
|
||||
if cmd.Stdout == nil {
|
||||
|
@ -83,7 +83,7 @@ func (e *execRunner) RunCmd(cmd *exec.Cmd) (*RunResult, error) {
|
|||
}
|
||||
|
||||
// Copy copies a file and its permissions
|
||||
func (e *execRunner) Copy(f assets.CopyableFile) error {
|
||||
func (*execRunner) Copy(f assets.CopyableFile) error {
|
||||
targetPath := path.Join(f.GetTargetDir(), f.GetTargetName())
|
||||
if _, err := os.Stat(targetPath); err == nil {
|
||||
if err := os.Remove(targetPath); err != nil {
|
||||
|
@ -112,7 +112,7 @@ do you have the correct permissions?`,
|
|||
}
|
||||
|
||||
// Remove removes a file
|
||||
func (e *execRunner) Remove(f assets.CopyableFile) error {
|
||||
func (*execRunner) Remove(f assets.CopyableFile) error {
|
||||
targetPath := filepath.Join(f.GetTargetDir(), f.GetTargetName())
|
||||
return os.Remove(targetPath)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue