Skip to content
This repository has been archived by the owner on Sep 2, 2022. It is now read-only.

Commit

Permalink
Make sure hostname is queried in local mode
Browse files Browse the repository at this point in the history
  • Loading branch information
gildub committed Sep 5, 2019
1 parent ef9d17c commit c67e3b4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
13 changes: 12 additions & 1 deletion pkg/env/env.go
Expand Up @@ -121,6 +121,9 @@ func surveyMissingValues() error {
}
viperConfig.Set("FetchFromRemote", true)
case "local":
if err := surveyHostname(); err != nil {
return err
}
viperConfig.Set("FetchFromRemote", false)
default:
return errors.New("Accepted values for config-source are: remote or local")
Expand Down Expand Up @@ -207,7 +210,7 @@ func surveyReporting() error {
return nil
}

func surveySSHConfigValues() error {
func surveyHostname() error {
hostname := viperConfig.GetString("Hostname")
if !viperConfig.InConfig("hostname") && hostname == "" {
discoverCluster := ""
Expand Down Expand Up @@ -253,6 +256,14 @@ func surveySSHConfigValues() error {
viperConfig.Set("ClusterName", clusterName)
}

return nil
}

func surveySSHConfigValues() error {
if err := surveyHostname(); err != nil {
return err
}

login := viperConfig.GetString("SSHLogin")
if !viperConfig.InConfig("sshlogin") && login == "" {
prompt := &survey.Input{
Expand Down
1 change: 1 addition & 0 deletions pkg/env/env_test.go
Expand Up @@ -112,6 +112,7 @@ func TestInitFromEnv(t *testing.T) {
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
os.Setenv("CPMA_CLUSTERNAME", "somename")
os.Setenv("CPMA_HOSTNAME", "master.example.org")
os.Setenv("CPMA_MANIFESTS", "true")
os.Setenv("CPMA_REPORTING", "true")
os.Setenv("CPMA_SAVECONFIG", "false")
Expand Down

0 comments on commit c67e3b4

Please sign in to comment.