Skip to content

Commit

Permalink
Log in to public ECR for E2E test
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisdoherty4 committed Apr 17, 2024
1 parent 45b8acb commit 67dc6de
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
22 changes: 22 additions & 0 deletions internal/test/e2e/ecr.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package e2e

import (
"fmt"

"github.com/aws/eks-anywhere/internal/pkg/ssm"

Check failure on line 6 in internal/test/e2e/ecr.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gci`-ed with -s standard -s default -s prefix(github.com/aws/eks-anywhere) --custom-order (gci)

"github.com/go-logr/logr"

Check failure on line 8 in internal/test/e2e/ecr.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gci`-ed with -s standard -s default -s prefix(github.com/aws/eks-anywhere) --custom-order (gci)
)

func (e *E2ESession) loginToPublicECR() error {
e.logger.V(1).Info("Logging in to public ECR")

command := "aws ecr-public get-login-password | 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
}
5 changes: 5 additions & 0 deletions internal/test/e2e/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 67dc6de

Please sign in to comment.