Skip to content

Commit

Permalink
Use the selected environment name to choose jump hosts (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamgoose authored Aug 3, 2022
1 parent d012110 commit 4e9417e
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions cmd/shellNode.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,18 +132,16 @@ func execSSHCommand(hostname string, username string, jump string, sshCmd []stri
}

func getJump() (string, error) {
kubeconfigName, err := getKubeconfigName()
if err != nil {
return "", err
env := viper.GetString("TRUSS_ENV")
if env == "" {
return "", nil
}

clusterEnv := strings.Replace(kubeconfigName, "kubeconfig-truss-", "", 1)

jump := viper.GetString("jumps." + clusterEnv)
jumps := viper.GetStringMapString("jumps")
jump := jumps[env]
if jump == "" {
return "", errors.New("Could not find jump for " + clusterEnv)
return "", fmt.Errorf("unknown env %v", env)
}

return jump, nil
}

Expand Down

0 comments on commit 4e9417e

Please sign in to comment.