Merge pull request #94049 from harche/ssh_user

Read ssh username from env variable
This commit is contained in:
Kubernetes Prow Robot 2020-08-26 18:23:02 -07:00 committed by GitHub
commit 38086508f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -19,6 +19,7 @@ package remote
import ( import (
"flag" "flag"
"fmt" "fmt"
"os"
"os/exec" "os/exec"
"os/user" "os/user"
"strings" "strings"
@ -68,6 +69,11 @@ func GetHostnameOrIP(hostname string) string {
if ip, found := hostnameIPOverrides.m[hostname]; found { if ip, found := hostnameIPOverrides.m[hostname]; found {
host = ip host = ip
} }
if *sshUser == "" {
*sshUser = os.Getenv("KUBE_SSH_USER")
}
if *sshUser != "" { if *sshUser != "" {
host = fmt.Sprintf("%s@%s", *sshUser, host) host = fmt.Sprintf("%s@%s", *sshUser, host)
} }