Don't assume we always SSH as the current user

This works on gcloud (where the user is dynamically created by the tool),
but doesn't hold on other clouds (e.g. AWS).

The function in pkg/util now takes a user arg, and it is called only
from the e2e tests, which now check for env-var KUBE_SSH_USER, and then
fall back to the existing behaviour of env-var USER.

I am using this from Jenkins by directly setting the env-var:

export KUBE_SSH_USER=jenkins
...
hack/jenkins/e2e.sh
This commit is contained in:
Justin Santa Barbara
2015-06-16 07:12:25 -04:00
parent ff0546da4f
commit efdd03a6a9
3 changed files with 115 additions and 8 deletions

View File

@@ -1161,7 +1161,9 @@ func SSH(cmd, host, provider string) (string, string, int, error) {
return "", "", 0, fmt.Errorf("error getting signer for provider %s: '%v'", provider, err)
}
return util.RunSSHCommand(cmd, host, signer)
user := os.Getenv("KUBE_SSH_USER")
// RunSSHCommand will default to Getenv("USER") if user == ""
return util.RunSSHCommand(cmd, user, host, signer)
}
// getSigner returns an ssh.Signer for the provider ("gce", etc.) that can be