From eaf63314b306e249935ff9d6b4a9f98fef1499f1 Mon Sep 17 00:00:00 2001 From: Amit Watve Date: Mon, 5 Apr 2021 13:49:53 -0700 Subject: [PATCH] Let CI override user. --- kubetest2-gce/deployer/common.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/kubetest2-gce/deployer/common.go b/kubetest2-gce/deployer/common.go index 63f9fc56..f09bf5e4 100644 --- a/kubetest2-gce/deployer/common.go +++ b/kubetest2-gce/deployer/common.go @@ -107,12 +107,11 @@ func (d *deployer) buildEnv() []string { // which is by default disabled on GCE VMs if USER is root. In order // for the deployer to work without fuss when run as root (like it // does by default in Prow) we can simply change USER to be something - // non-root. USER is not always set in a given environment, so the UID - // is checked instead for guaranteed correct information. - if uid := os.Getuid(); uid == 0 { - env = append(env, fmt.Sprintf("USER=%s", "kubetest2")) + // non-root. + if user, ok := os.LookupEnv("USER"); ok && user != "root" { + env = append(env, fmt.Sprintf("USER=%s", user)) } else { - env = append(env, fmt.Sprintf("USER=%s", os.Getenv("USER"))) + env = append(env, fmt.Sprintf("USER=%s", "kubetest2")) } // kube-up.sh, kube-down.sh etc. use PROJECT as a parameter