From ef76bf9164a598f4ee6b8bfa04da3124554ecc37 Mon Sep 17 00:00:00 2001 From: Davanum Srinivas Date: Fri, 30 Aug 2024 07:56:46 -0400 Subject: [PATCH] Use keys specified in env vars for GCP and AWS Signed-off-by: Davanum Srinivas --- tests/e2e/kubetest2-kops/deployer/common.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/e2e/kubetest2-kops/deployer/common.go b/tests/e2e/kubetest2-kops/deployer/common.go index d2e25ce882..47c2a3eb9b 100644 --- a/tests/e2e/kubetest2-kops/deployer/common.go +++ b/tests/e2e/kubetest2-kops/deployer/common.go @@ -51,6 +51,12 @@ func (d *deployer) initialize() error { switch d.CloudProvider { case "aws": + if d.SSHPrivateKeyPath == "" { + d.SSHPrivateKeyPath = os.Getenv("AWS_SSH_PRIVATE_KEY_FILE") + } + if d.SSHPublicKeyPath == "" { + d.SSHPublicKeyPath = os.Getenv("AWS_SSH_PUBLIC_KEY_FILE") + } if d.SSHPrivateKeyPath == "" || d.SSHPublicKeyPath == "" { publicKeyPath, privateKeyPath, err := util.CreateSSHKeyPair(d.ClusterName) if err != nil { @@ -90,6 +96,12 @@ func (d *deployer) initialize() error { d.GCPProject = resource.Name klog.V(1).Infof("Got project %s from boskos", d.GCPProject) + if d.SSHPrivateKeyPath == "" { + d.SSHPrivateKeyPath = os.Getenv("GCE_SSH_PRIVATE_KEY_FILE") + } + if d.SSHPublicKeyPath == "" { + d.SSHPublicKeyPath = os.Getenv("GCE_SSH_PUBLIC_KEY_FILE") + } if d.SSHPrivateKeyPath == "" && d.SSHPublicKeyPath == "" { privateKey, publicKey, err := gce.SetupSSH(d.GCPProject) if err != nil { @@ -98,12 +110,15 @@ func (d *deployer) initialize() error { d.SSHPrivateKeyPath = privateKey d.SSHPublicKeyPath = publicKey } + d.createBucket = true } else if d.SSHPrivateKeyPath == "" && os.Getenv("KUBE_SSH_KEY_PATH") != "" { d.SSHPrivateKeyPath = os.Getenv("KUBE_SSH_KEY_PATH") } } + klog.V(1).Infof("Using SSH keypair: [%s,%s]", d.SSHPrivateKeyPath, d.SSHPublicKeyPath) + if d.commonOptions.ShouldBuild() { if err := d.verifyBuildFlags(); err != nil { return fmt.Errorf("init failed to check build flags: %v", err) @@ -113,6 +128,8 @@ func (d *deployer) initialize() error { if d.SSHUser == "" { d.SSHUser = os.Getenv("KUBE_SSH_USER") } + klog.V(1).Infof("Using SSH user: [%s]", d.SSHUser) + if d.TerraformVersion != "" { t, err := target.NewTerraform(d.TerraformVersion) if err != nil {