Skip to content

Comments

Migrate Docker registry handler to AWS SDK v2#23

Open
JamieMagee wants to merge 1 commit intomainfrom
jamiemagee/aws-sdk-go-v2
Open

Migrate Docker registry handler to AWS SDK v2#23
JamieMagee wants to merge 1 commit intomainfrom
jamiemagee/aws-sdk-go-v2

Conversation

@JamieMagee
Copy link
Member

@JamieMagee JamieMagee commented Feb 3, 2026

Replaces aws-sdk-go (v1) with aws-sdk-go-v2 for ECR authentication in the Docker registry handler.

What changed

  • Swapped session.NewSession() for config.LoadDefaultConfig()
  • Static credentials now use credentials.NewStaticCredentialsProvider()
  • GetAuthorizationToken takes a context.Context parameter
  • Defined an ECRClient interface since v2 removed the ecriface package
  • Pointer dereferencing uses aws.ToString() helper
  • AuthorizationData is now a slice of values, not pointers

Why

AWS deprecated v1 in July 2024 and recommends migrating to v2.

Copilot AI review requested due to automatic review settings February 3, 2026 23:20
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR migrates the Docker registry handler’s ECR integration from AWS SDK v1 to AWS SDK v2 to address deprecation and take advantage of the newer SDK’s improvements.

Changes:

  • Replaces aws-sdk-go v1 ECR client/session usage with aws-sdk-go-v2 equivalents, including new configuration and credentials providers.
  • Introduces a local ECRClient interface and updates the Docker registry handler and tests to use the new v2 method signatures and types.
  • Updates go.mod dependencies to remove AWS v1 and add the necessary AWS v2 modules and indirect dependencies.

Reviewed changes

Copilot reviewed 3 out of 537 changed files in this pull request and generated 1 comment.

File Description
internal/handlers/docker_registry.go Swaps in AWS SDK v2 for ECR auth, adds an ECRClient interface, and adjusts token handling to v2 APIs.
internal/handlers/docker_registry_test.go Updates the ECR mock and imports to conform to the new v2 client interface and response types.
go.mod Removes AWS SDK v1 and adds AWS SDK v2 core, config, credentials, and ECR service modules plus related indirect deps.

Comment on lines +201 to 205
rsp, err := ecrSvc.GetAuthorizationToken(context.Background(), &ecr.GetAuthorizationTokenInput{})
if err != nil {
logging.RequestLogf(ctx, "! failed to get ecr authorization token (key_id=%s)", c.username)
return false
}
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using context.Background() inside a request-handling path makes the ECR call uncancellable and detached from the lifecycle of the incoming HTTP request; it would be better to derive the context from the current request (for example, via the *goproxy.ProxyCtx’s underlying *http.Request) so that client disconnects or timeouts can propagate to this AWS call.

Copilot uses AI. Check for mistakes.
Replace aws-sdk-go with aws-sdk-go-v2 for ECR authentication.

Changes:
- Use config.LoadDefaultConfig() instead of session.NewSession()
- Use credentials.NewStaticCredentialsProvider() for static creds
- Add context.Context to GetAuthorizationToken calls
- Define ECRClient interface (v2 removed ecriface)
- Use aws.ToString() helper for pointer dereferencing
- Update AuthorizationData from pointer slice to value slice
@JamieMagee JamieMagee force-pushed the jamiemagee/aws-sdk-go-v2 branch from 32a29c2 to 5211eae Compare February 8, 2026 21:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant