From 7bf18bb2f1d467f0b0e220b754206109c4611a4e Mon Sep 17 00:00:00 2001 From: Chris Doherty Date: Thu, 18 Apr 2024 13:34:53 -0500 Subject: [PATCH] Log in to public ECR for E2E test (#8001) --- internal/test/e2e/ecr.go | 22 ++++++++++++++++++++++ internal/test/e2e/setup.go | 5 +++++ 2 files changed, 27 insertions(+) create mode 100644 internal/test/e2e/ecr.go diff --git a/internal/test/e2e/ecr.go b/internal/test/e2e/ecr.go new file mode 100644 index 000000000000..9738ba09e7a2 --- /dev/null +++ b/internal/test/e2e/ecr.go @@ -0,0 +1,22 @@ +package e2e + +import ( + "fmt" + + "github.com/go-logr/logr" + + "github.com/aws/eks-anywhere/internal/pkg/ssm" +) + +func (e *E2ESession) loginToPublicECR() error { + e.logger.V(1).Info("Logging in to public ECR") + + command := "aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws" + if err := ssm.Run(e.session, logr.Discard(), e.instanceId, command, ssmTimeout); err != nil { + return fmt.Errorf("sign in to public ecr: %v", err) + } + + e.logger.V(1).Info("Logged in to public ECR") + + return nil +} diff --git a/internal/test/e2e/setup.go b/internal/test/e2e/setup.go index 554d4c98f995..27d1f1aa58ff 100644 --- a/internal/test/e2e/setup.go +++ b/internal/test/e2e/setup.go @@ -178,6 +178,11 @@ func (e *E2ESession) setup(regex string) error { return err } + err = e.loginToPublicECR() + if err != nil { + return err + } + ipPool := e.ipPool.ToString() if ipPool != "" { e.testEnvVars[e2etests.ClusterIPPoolEnvVar] = ipPool