Skip to content

Add ECR Public authentication: aws/ecr-public integration and atmos aws ecr login --public - #2231

Merged
Andriy Knysh (aknysh) merged 17 commits into
mainfrom
osterman/ecr-public-auth
Jun 2, 2026
Merged

Andriy Knysh (aknysh) merged 17 commits into
mainfrom
osterman/ecr-public-auth

Conversation

@osterman

@osterman Erik Osterman (Cloud Posse) (osterman) commented Mar 18, 2026 •

Copy link
Copy Markdown
Member

what

Add ECR Public authentication to Atmos for authenticated access to public.ecr.aws, solving Docker rate limiting on public ECR images. Two entry points:

  • atmos aws ecr login --public — direct, zero-config login using ambient AWS credentials (the AWS SDK default chain: env, shared config/profile, SSO, IMDS/IRSA/ECS), or --public --identity <name> to use a specific identity. Ideal for CI.
  • aws/ecr-public integration kind — for automatic login on atmos auth login and identity linking.

Key changes:

  • Command (cmd/aws/ecr/login.go): new --public flag on atmos aws ecr login; ambient-credential and identity-based ECR Public login paths; mutually exclusive with a positional integration argument and --registry.
  • Cloud layer (pkg/auth/cloud/aws/ecr_public.go): GetPublicAuthorizationToken() calls ecrpublic:GetAuthorizationToken, always in us-east-1.
  • Integration layer (pkg/auth/integrations/aws/ecr_public.go): ECRPublicIntegration factory registering the aws/ecr-public kind, with region validation at config time. Implements the full Integration interface including Cleanup() (docker logout) and Environment() (DOCKER_CONFIG).
  • Region validation: rejects unsupported regions (only us-east-1 and us-west-2 have service endpoints; auth is us-east-1 only).
  • Tests: cloud-layer and integration-layer unit tests (token retrieval, region validation, cleanup, error handling) with a generated mock ECR Public client; command tests for the --public flag and mode validation.
  • Documentation: atmos aws ecr login command reference (added --public flag), ECR authentication tutorial, and a PRD (docs/prd/ecr-public-authentication.md).
  • Blog post + roadmap: announcement and a shipped milestone linking to the changelog.

Note: this branch has been merged up to main. Following #2144 (atmos auth ecr-login → atmos aws ecr login), ECR login lives under the aws namespace, and the integration was adapted to main's evolved Integration interface (exported BuildAWSConfigFromCreds, new Cleanup/Environment methods).

why

Docker pulls from public.ecr.aws hit rate limits when unauthenticated. This blocks CI workflows, especially those using cloudposse/github-action-docker-build-push which pulls BuildKit/binfmt images on every run. Authenticated pulls have significantly higher (or no) rate limits.

Because public.ecr.aws is global, any valid AWS credentials unlock authenticated pulls — so --public with ambient credentials "just works" in CI with zero configuration. ECR Public otherwise differs from private ECR: it uses the ecrpublic SDK service, a bearer token instead of SigV4, a hardcoded us-east-1 auth region, and a fixed public.ecr.aws registry URL. It requires ecr-public:GetAuthorizationToken and sts:GetServiceBearerToken IAM permissions.

references

Summary by CodeRabbit

  • New Features

    • ECR Public authentication (aws/ecr-public) with atmos aws ecr login --public, identity-driven auto-provisioning, and enforced us-east-1 auth.
  • Documentation

    • Tutorials, blog post, and roadmap updated with ECR Public examples, permissions, CI guidance, and troubleshooting.
  • Bug Fixes

    • Improved identity selection UX (confirmation message) and safer CLI behavior for non‑TTY identity selection.
  • Tests

    • Extensive unit and integration tests covering ECR Public flows and CLI routing.
  • Chores

    • NOTICE/dependencies updated and minor .gitignore tweak.

…c registry access

- Add ECR Public support via new aws/ecr-public integration kind
- Implement region validation (us-east-1 and us-west-2 supported)
- Add cloud layer with GetPublicAuthorizationToken and region validation
- Add integration layer with factory and execution
- Update documentation for ecr-login command and tutorial
- Add blog post announcing feature
- Update roadmap with shipped milestone

Closes #2079 (as part of Native CI/CD integration feature)
@github-actions github-actions Bot added the size/l Large size PR label Mar 18, 2026
@github-actions

github-actions Bot commented Mar 18, 2026 •

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues found.

Scanned Files

  • go.mod

@mergify

mergify Bot commented Mar 18, 2026

Copy link
Copy Markdown
Contributor

Important

Cloud Posse Engineering Team Review Required

This pull request modifies files that require Cloud Posse's review. Please be patient, and a core maintainer will review your changes.

To expedite this process, reach out to us on Slack in the #pr-reviews channel.

@mergify mergify Bot added the needs-cloudposse Needs Cloud Posse assistance label Mar 18, 2026
@coderabbitai

coderabbitai Bot commented Mar 18, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6a4604b9-9bdd-4de6-aab7-b58a8272f164

📥 Commits

Reviewing files that changed from the base of the PR and between 507c230 and 6a39939.

📒 Files selected for processing (3)
  • cmd/aws/ecr/login.go
  • errors/errors.go
  • pkg/auth/manager.go
🚧 Files skipped from review as they are similar to previous changes (3)
  • pkg/auth/manager.go
  • errors/errors.go
  • cmd/aws/ecr/login.go

📝 Walkthrough

Walkthrough

Adds ECR Public authentication: NOTICE/roadmap/docs updates, new ECR Public error sentinels, CLI --public routing with identity resolution and testing seams, integration wiring and mocks, and extensive unit/integration tests.

Changes

ECR Public authentication for Atmos CLI

Layer / File(s) Summary
Docs, NOTICE and roadmap
website/src/data/roadmap.js, docs/prd/ecr-public-authentication.md, NOTICE, .gitignore, website/blog/*
Adds PRD, blog and tutorial docs for aws/ecr-public, records github.com/aws/aws-sdk-go-v2/service/ecrpublic in NOTICE, bumps roadmap milestone, and ignores a local lock file.
CLI command structure and identity resolution
cmd/aws/ecr/login.go
Adds --public flag, refactors executeLoginCommand with mode validation and publicLogin flows, introduces testing seams for AWS calls, and adds resolveSelectedIdentity with SIGINT-wrapped abort handling.
CLI tests and test seams
cmd/aws/ecr/login_test.go
Expands tests for --public flag, validateLoginModes, resolveSelectedIdentity (TTY/no-TTY and abort wrapping), publicLogin/ambient/identity flows, explicit registry handling, and dispatch routing.
Integrations, mocks and integration tests
pkg/auth/integrations/*, pkg/auth/integrations/*_test.go, pkg/auth/*_test.go
Adds aws/ecr-public integration constructor and Execute/Cleanup/Environment tests, docker-write test doubles, gomock-generated mocks, and comprehensive integration/unit tests validating token parsing, error paths, and docker config side effects.
Integration kind, errors and manager UI
pkg/auth/integrations/types.go, errors/errors.go, pkg/auth/manager.go
Adds KindAWSECRPublic constant, new sentinels ErrECRPublicAuthFailed and ErrECRPublicInvalidRegion, removes ErrECRIdentitySelect, and echoes selected identity via UI after interactive selection.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • cloudposse/atmos#2144: Modifies the same cmd/aws/ecr/login.go auth-manager and identity-selection flow that this PR extends with --public and resolveSelectedIdentity.
  • cloudposse/atmos#1859: Related ECR authentication changes and sentinel error updates intersecting this PR's error sentinel edits.

Suggested reviewers

  • aknysh
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 77.78% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly and clearly describes the main changes: adding ECR Public authentication via a new integration kind and CLI flag.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch osterman/ecr-public-auth

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 5

🧹 Nitpick comments (3)
pkg/auth/cloud/aws/ecr_public.go (1)

26-32: Don't export a mutable region set.

ECRPublicSupportedRegions behaves like constant data, but exposing it as a writable map lets any caller change validation globally and makes concurrent access fragile. Keep the set private and expose a helper or copy if other packages need the list.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/auth/cloud/aws/ecr_public.go` around lines 26 - 32,
ECRPublicSupportedRegions is exported as a mutable map which lets callers modify
global state; make it unexported (rename to ecrPublicSupportedRegions) and stop
exposing the map directly, then add a safe accessor: either a function
IsECRPublicSupportedRegion(region string) bool for validation or a
GetECRPublicSupportedRegions() []string that returns a new slice copy of keys;
update callers to use the new accessor and remove direct map usage to prevent
concurrent mutation and preserve immutability.
pkg/auth/integrations/aws/ecr_public_test.go (1)

31-35: Test the interface contract, not the struct internals.

These assertions downcast to *ECRPublicIntegration and inspect private fields, so harmless implementation refactors will break the suite. Prefer asserting Kind() and GetIdentity() on the returned interface instead.

Based on learnings "Test behavior, not implementation; never test stub functions; avoid tautological tests; make code testable via DI; no coverage theater; remove always-skipped tests; use errors.Is() for error checking."

Also applies to: 50-52, 86-88

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/auth/integrations/aws/ecr_public_test.go` around lines 31 - 35, The test
currently downcasts to *ECRPublicIntegration and asserts private fields
(ecrPublicIntegration.name / identity); change it to test the interface contract
instead by using the returned integration variable's methods: assert
integration.Kind() equals the expected kind (e.g., "ecr-public") and assert
integration.GetIdentity() equals "dev-admin"; remove the downcast to
ECRPublicIntegration and the direct field assertions and apply the same
replacement for the other occurrences that inspect private fields (the blocks
referencing ECRPublicIntegration around the other failing assertions).
pkg/auth/integrations/aws/ecr_public.go (1)

36-52: Validate via.identity during construction for clearer failures.

identity is optional in this constructor today, so a bad config can fail later in execution with less actionable errors. Fail fast here when via.identity is empty.

Suggested validation
  identity := ""
  if config.Config.Via != nil {
    identity = config.Config.Via.Identity
  }
+ if identity == "" {
+   return nil, fmt.Errorf("%w: integration '%s': missing required via.identity", errUtils.ErrIntegrationFailed, config.Name)
+ }

  // Validate region if user specified one in spec.registry.

As per coding guidelines: "Provide clear error messages to users, include troubleshooting hints when appropriate, and log detailed errors for debugging."

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/auth/integrations/aws/ecr_public.go` around lines 36 - 52, The
constructor currently allows an empty via.identity and returns an
ECRPublicIntegration with identity == "" which defers failure; update the
initialization logic (where identity is derived from config.Config.Via and the
ECRPublicIntegration is returned) to validate that config.Config.Via != nil and
config.Config.Via.Identity is non-empty and, if not, return a clear error (wrap
with errUtils.ErrIntegrationFailed and include config.Name and a helpful message
about missing via.identity) before creating the ECRPublicIntegration instance;
keep the existing region validation for config.Config.Spec.Registry as-is.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@pkg/auth/cloud/aws/ecr_public_test.go`:
- Around line 11-140: Add unit tests for GetPublicAuthorizationToken that cover
all error and success branches: build a test suite in ecr_public_test.go that
injects a mocked ECR Public client (or a test double) into
GetPublicAuthorizationToken to simulate (1) AWS config build failure, (2) API
call returning an error, (3) API response with missing Auth token/ExpiresAt, (4)
API response with invalid base64 Auth token, (5) API response with decoded token
missing the "username:password" format, and (6) a successful response that
returns expected username/password; use table-driven tests and assert returned
error values or parsed credentials accordingly, referencing the
GetPublicAuthorizationToken function and the client method it calls
(GetAuthorizationToken) so tests remain resilient to line changes.

In `@pkg/auth/integrations/aws/ecr_public_test.go`:
- Around line 182-193: The test TestECRPublicIntegration_Execute_NilCredentials
only asserts an error for nil creds; add unit tests that exercise
ECRPublicIntegration.Execute's happy path and the failure branches (auth token
retrieval failure, docker-config write/login failure) by injecting mocks for any
external calls (e.g., credential provider, token fetcher, docker-config writer
or registry client) so you can simulate success and each error case; create
table-driven tests that call Execute with mocked credentials and assert expected
outcomes and side-effects (token used, docker config written, errors wrapped),
targeting >80% coverage for the pkg/auth/integrations/aws package and
referencing ECRPublicIntegration.Execute and any helper interfaces used for
token retrieval and docker-config operations.

In `@website/docs/cli/configuration/settings/pro.mdx`:
- Around line 185-191: The example YAML for the pro settings omits the required
workspace_id; update the snippet that defines settings.pro to include both token
(settings.pro.token) and workspace_id (settings.pro.workspace_id) so users can
copy/paste a complete bearer-token configuration, e.g., add the workspace_id key
alongside the token key under the pro section.

In `@website/docs/cli/configuration/version/use.mdx`:
- Around line 89-97: The precedence table and explanatory note disagree: update
the table so `--use-version` and the `ATMOS_VERSION_USE` env var appear at the
same priority level (i.e., both as Priority 1) and adjust the remaining
priorities accordingly, or alternatively change the note to state that the
`--use-version` flag sets `ATMOS_VERSION_USE` internally so the flag and the env
var share the same priority; ensure the table rows reference the exact symbols
`--use-version`, `ATMOS_VERSION_USE`, `ATMOS_VERSION`, and `version.use` so they
match the explanatory sentence.

In `@website/src/data/roadmap.js`:
- Line 175: The roadmap entry object with label 'ECR Public registry
authentication' is missing its pr reference; add a pr property to that object
(matching the style used elsewhere in roadmap.js, e.g. pr: '#1234' or pr:
'https://github.com/owner/repo/pull/1234') so the shipped milestone includes the
PR link, and ensure the new property follows the same quoting/comma formatting
as other entries.

---

Nitpick comments:
In `@pkg/auth/cloud/aws/ecr_public.go`:
- Around line 26-32: ECRPublicSupportedRegions is exported as a mutable map
which lets callers modify global state; make it unexported (rename to
ecrPublicSupportedRegions) and stop exposing the map directly, then add a safe
accessor: either a function IsECRPublicSupportedRegion(region string) bool for
validation or a GetECRPublicSupportedRegions() []string that returns a new slice
copy of keys; update callers to use the new accessor and remove direct map usage
to prevent concurrent mutation and preserve immutability.

In `@pkg/auth/integrations/aws/ecr_public_test.go`:
- Around line 31-35: The test currently downcasts to *ECRPublicIntegration and
asserts private fields (ecrPublicIntegration.name / identity); change it to test
the interface contract instead by using the returned integration variable's
methods: assert integration.Kind() equals the expected kind (e.g., "ecr-public")
and assert integration.GetIdentity() equals "dev-admin"; remove the downcast to
ECRPublicIntegration and the direct field assertions and apply the same
replacement for the other occurrences that inspect private fields (the blocks
referencing ECRPublicIntegration around the other failing assertions).

In `@pkg/auth/integrations/aws/ecr_public.go`:
- Around line 36-52: The constructor currently allows an empty via.identity and
returns an ECRPublicIntegration with identity == "" which defers failure; update
the initialization logic (where identity is derived from config.Config.Via and
the ECRPublicIntegration is returned) to validate that config.Config.Via != nil
and config.Config.Via.Identity is non-empty and, if not, return a clear error
(wrap with errUtils.ErrIntegrationFailed and include config.Name and a helpful
message about missing via.identity) before creating the ECRPublicIntegration
instance; keep the existing region validation for config.Config.Spec.Registry
as-is.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: f0ec1758-7b8d-42c3-ad11-a7dd27fe83bb

📥 Commits

Reviewing files that changed from the base of the PR and between 7f1f92b and ad31d13.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (18)
  • NOTICE
  • docs/prd/ecr-public-authentication.md
  • errors/errors.go
  • go.mod
  • pkg/auth/cloud/aws/ecr_public.go
  • pkg/auth/cloud/aws/ecr_public_test.go
  • pkg/auth/integrations/aws/ecr_public.go
  • pkg/auth/integrations/aws/ecr_public_test.go
  • pkg/auth/integrations/types.go
  • website/blog/2026-03-18-ecr-public-authentication.mdx
  • website/docs/cli/commands/auth/ecr-login.mdx
  • website/docs/cli/configuration/configuration.mdx
  • website/docs/cli/configuration/settings/pro.mdx
  • website/docs/cli/configuration/version/use.mdx
  • website/docs/cli/configuration/version/version.mdx
  • website/docs/cli/environment-variables.mdx
  • website/docs/tutorials/ecr-authentication.mdx
  • website/src/data/roadmap.js

Comment thread pkg/auth/cloud/aws/ecr_public_test.go Resolved
Comment thread website/src/data/roadmap.js Resolved
@codecov

codecov Bot commented Mar 18, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.53254% with 16 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@8dc0bc0). Learn more about missing BASE report.

Files with missing lines Patch % Lines
cmd/aws/ecr/login.go 84.84% 6 Missing and 4 partials ⚠️
pkg/auth/integrations/aws/ecr_public.go 93.22% 2 Missing and 2 partials ⚠️
pkg/auth/cloud/aws/ecr_public.go 97.67% 1 Missing ⚠️
pkg/auth/manager.go 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #2231   +/-   ##
=======================================
  Coverage        ?   78.79%           
=======================================
  Files           ?     1194           
  Lines           ?   114104           
  Branches        ?        0           
=======================================
  Hits            ?    89905           
  Misses          ?    19261           
  Partials        ?     4938           
Flag Coverage Δ
unittests 78.79% <90.53%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
errors/errors.go 100.00% <ø> (ø)
pkg/auth/cloud/aws/ecr_public.go 97.67% <97.67%> (ø)
pkg/auth/manager.go 82.98% <0.00%> (ø)
pkg/auth/integrations/aws/ecr_public.go 93.22% <93.22%> (ø)
cmd/aws/ecr/login.go 83.06% <84.84%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

- Add unit tests for GetPublicAuthorizationToken covering all error/success branches
- Add unit tests for ECRPublicIntegration.Execute happy path and failure branches
- Introduce ECRPublicClient interface with options pattern for testability
- Add injectable dependencies to ECRPublicIntegration for mock-based testing
- Fix missing workspace_id in pro.mdx bearer-token example
- Fix precedence table contradiction in version/use.mdx
- Add pr: 2231 to ECR Public roadmap milestone

Coverage: cloud/aws 81.5%, integrations/aws 87.0% (both above 80% threshold)

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@mergify

mergify Bot commented Mar 18, 2026

Copy link
Copy Markdown
Contributor

💥 This pull request now has conflicts. Could you fix it Erik Osterman (Cloud Posse) (@osterman)? 🙏

@mergify mergify Bot added the conflict This PR has conflicts label Mar 18, 2026
Resolve conflicts in pro.mdx and version/use.mdx docs, accepting
main's simplified bearer-token example and expanded version precedence table.

Co-Authored-By: Claude Opus 4.6 <[email protected]>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (3)
pkg/auth/cloud/aws/ecr_public.go (2)

56-61: Add tracing to the exported option helper.

WithECRPublicClient is public, but it skips the perf.Track hook used by the other public functions in this file. Keeping that contract consistent avoids holes in tracing.

♻️ Proposed fix
 func WithECRPublicClient(client ECRPublicClient) ECRPublicAuthOption {
+	defer perf.Track(nil, "aws.WithECRPublicClient")()
+
 	return func(c *ecrPublicAuthConfig) {
 		c.client = client
 	}
 }

As per coding guidelines: "Add defer perf.Track(atmosConfig, "pkg.FuncName")() + blank line to all public functions, use nil if no atmosConfig param".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/auth/cloud/aws/ecr_public.go` around lines 56 - 61, The exported helper
WithECRPublicClient is missing the perf.Track tracing hook used by other public
functions; update WithECRPublicClient (the function that returns
ECRPublicAuthOption and mutates ecrPublicAuthConfig) to call defer
perf.Track(nil, "pkg.WithECRPublicClient")() as the first statement in the
function body and add a blank line after that defer to match the file's
convention so tracing is consistent for all public helpers.

34-39: Pin the mock generator version.

Using go run ...mockgen@latest makes the generated file depend on whatever version is current when go generate runs. Please lock this to a fixed version, ideally the one already declared in go.mod, so mock output stays reproducible.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/auth/cloud/aws/ecr_public.go` around lines 34 - 39, Replace the
go:generate directive that currently uses "go run
go.uber.org/mock/mockgen@latest" with a pinned module version: run "go list -m
-json go.uber.org/mock/mockgen" or inspect go.mod to find the exact version
used, then change the directive to "go run go.uber.org/mock/mockgen@<version>"
(keeping the same -source=ecr_public.go and
-destination=mock_ecr_public_client_test.go flags). This ensures the mock for
ECRPublicClient is reproducible; update the go:generate line in the same file
where ECRPublicClient is declared.
pkg/auth/integrations/aws/ecr_public_test.go (1)

204-219: Generate the Docker writer mock instead of hand-rolling it.

This double only captures arguments; it can't express expectations like "must not be called", so the token-error path still can't prove WriteAuth was skipped. Please switch dockerAuthWriter to a mockgen-generated mock like the ECRPublicClient one in this PR.

As per coding guidelines: "Use go.uber.org/mock/mockgen with //go:generate directives for mock generation - never create manual mocks".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@pkg/auth/integrations/aws/ecr_public_test.go` around lines 204 - 219, The
test uses a hand-rolled mock type mockDockerWriter and its WriteAuth method
which only captures args and cannot express expectations (e.g. "must not be
called"); replace it with a mockgen-generated mock for the dockerAuthWriter
interface (similar to the ECRPublicClient mock used elsewhere). Add a
//go:generate directive for go.uber.org/mock/mockgen, run mockgen to produce the
concrete mock type, update tests to import and use that generated mock (set
EXPECT() expectations like NotToBeCalled or Return) and remove the manual
mockDockerWriter type and its WriteAuth implementation so tests can assert
call/non-call behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@website/src/data/roadmap.js`:
- Line 175: Find the initiatives array and update the auth initiative's progress
field (the object with label: 'auth') to account for the newly shipped milestone
— change progress from 80 to 81 so the roadmap bar reflects the added shipped
item; ensure the new milestone already includes pr: 2231 and changelog:
'ecr-public-authentication' as shown.

---

Nitpick comments:
In `@pkg/auth/cloud/aws/ecr_public.go`:
- Around line 56-61: The exported helper WithECRPublicClient is missing the
perf.Track tracing hook used by other public functions; update
WithECRPublicClient (the function that returns ECRPublicAuthOption and mutates
ecrPublicAuthConfig) to call defer perf.Track(nil, "pkg.WithECRPublicClient")()
as the first statement in the function body and add a blank line after that
defer to match the file's convention so tracing is consistent for all public
helpers.
- Around line 34-39: Replace the go:generate directive that currently uses "go
run go.uber.org/mock/mockgen@latest" with a pinned module version: run "go list
-m -json go.uber.org/mock/mockgen" or inspect go.mod to find the exact version
used, then change the directive to "go run go.uber.org/mock/mockgen@<version>"
(keeping the same -source=ecr_public.go and
-destination=mock_ecr_public_client_test.go flags). This ensures the mock for
ECRPublicClient is reproducible; update the go:generate line in the same file
where ECRPublicClient is declared.

In `@pkg/auth/integrations/aws/ecr_public_test.go`:
- Around line 204-219: The test uses a hand-rolled mock type mockDockerWriter
and its WriteAuth method which only captures args and cannot express
expectations (e.g. "must not be called"); replace it with a mockgen-generated
mock for the dockerAuthWriter interface (similar to the ECRPublicClient mock
used elsewhere). Add a //go:generate directive for go.uber.org/mock/mockgen, run
mockgen to produce the concrete mock type, update tests to import and use that
generated mock (set EXPECT() expectations like NotToBeCalled or Return) and
remove the manual mockDockerWriter type and its WriteAuth implementation so
tests can assert call/non-call behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 54c6a18b-9cf1-4e9a-92b2-a7e24ed15260

📥 Commits

Reviewing files that changed from the base of the PR and between ad31d13 and c05b722.

📒 Files selected for processing (8)
  • pkg/auth/cloud/aws/ecr_public.go
  • pkg/auth/cloud/aws/ecr_public_test.go
  • pkg/auth/cloud/aws/mock_ecr_public_client_test.go
  • pkg/auth/integrations/aws/ecr_public.go
  • pkg/auth/integrations/aws/ecr_public_test.go
  • website/docs/cli/configuration/settings/pro.mdx
  • website/docs/cli/configuration/version/use.mdx
  • website/src/data/roadmap.js
🚧 Files skipped from review as they are similar to previous changes (3)
  • website/docs/cli/configuration/version/use.mdx
  • pkg/auth/cloud/aws/ecr_public_test.go
  • pkg/auth/integrations/aws/ecr_public.go

Comment thread website/src/data/roadmap.js Resolved
@mergify

mergify Bot commented Mar 21, 2026

Copy link
Copy Markdown
Contributor

💥 This pull request now has conflicts. Could you fix it Erik Osterman (Cloud Posse) (@osterman)? 🙏

@mergify mergify Bot added the conflict This PR has conflicts label Mar 21, 2026
@mergify mergify Bot removed the conflict This PR has conflicts label May 2, 2026
@mergify

mergify Bot commented May 2, 2026

Copy link
Copy Markdown
Contributor

💥 This pull request now has conflicts. Could you fix it Erik Osterman (Cloud Posse) (@osterman)? 🙏

@mergify mergify Bot added the conflict This PR has conflicts label May 2, 2026
@atmos-pro

atmos-pro Bot commented May 30, 2026 •

Copy link
Copy Markdown
Contributor

Tip

Atmos Pro  

No affected stacks workflow was detected for this pull request.
If this is expected, no action is needed.
Learn More. Ask AI.

coderabbitai[bot]
coderabbitai Bot previously approved these changes May 30, 2026
Resolve conflicts arising from main's PR #2144 (refactor(auth): move ECR
login from auth to aws namespace), which renamed `atmos auth ecr-login` ->
`atmos aws ecr login` and relocated its docs from cli/commands/auth/ to
cli/commands/aws/.

- errors/errors.go: keep both the ECR Public and EKS error blocks.
- pkg/auth/integrations/types.go: keep KindAWSECRPublic alongside the now-
  implemented KindAWSEKS (dropped the stale "Future" comment).
- ecr-login.mdx / ecr-authentication.mdx / blog: align all ECR Public examples
  to the canonical `atmos aws ecr login` command name.
- roadmap.js: recompute auth initiative progress to 93 (28 shipped / 30 total
  after the merge adds the ECR Public registry authentication milestone).

Adapt the branch's ECR Public integration to main's evolved interfaces:
- Use the now-exported BuildAWSConfigFromCreds helper.
- Implement Cleanup() and Environment() on ECRPublicIntegration, mirroring the
  private ECRIntegration (interface gained these methods in main).
- Add errWrapFmt constant for the repeated "%w: %w" wrap format (revive).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
coderabbitai[bot]
coderabbitai Bot previously approved these changes May 31, 2026
Add unit tests for the ECR Public login paths that were below the 80%
Codecov patch target:

- cmd/aws/ecr: 39.8% -> 87.6%. Introduce package-level function-var
  seams (loadDefaultAWSCredentials, getPublicAuthorizationToken,
  getAuthorizationToken) and make createAuthManager a var, mirroring the
  existing seam pattern in pkg/auth/integrations/aws/ecr.go, so the login
  helpers can be unit-tested with stubs and a mock AuthManager. No
  behavior change.
- pkg/auth/integrations/aws: cover ECRPublicIntegration Cleanup and
  Environment via the existing ecrDockerConfigFactory seam.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@mergify

mergify Bot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

💥 This pull request now has conflicts. Could you fix it Erik Osterman (Cloud Posse) (@osterman)? 🙏

@mergify mergify Bot added the conflict This PR has conflicts label Jun 1, 2026
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jun 1, 2026
Document the full "log in then pull directly" path in the ECR Public
changelog post: add the --public --identity variant, a docker pull
example, and a note that credentials are written to the standard Docker
config ($DOCKER_CONFIG or ~/.docker/config.json) so plain docker pull
works without atmos auth exec (tokens last ~12h).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@aknysh
Andriy Knysh (aknysh) merged commit edca67f into main Jun 2, 2026
61 checks passed
@aknysh
Andriy Knysh (aknysh) deleted the osterman/ecr-public-auth branch June 2, 2026 01:43
@atmos-pro

atmos-pro Bot commented Jun 2, 2026 •

Copy link
Copy Markdown
Contributor

Tip

Atmos Pro  

No affected stacks workflow was detected for this pull request.
If this is expected, no action is needed.
Learn More. Ask AI.

@mergify mergify Bot removed the needs-cloudposse Needs Cloud Posse assistance label Jun 2, 2026
@github-actions

github-actions Bot commented Jun 2, 2026

Copy link
Copy Markdown

Warning

Release Documentation Required

This PR is labeled minor or major and requires documentation updates:

  • Changelog entry - Add a blog post in website/blog/YYYY-MM-DD-feature-name.mdx
  • Roadmap update - Update website/src/data/roadmap.js with the new milestone

Alternatively: If this change doesn't require release documentation, remove the minor or major label.

@github-actions

github-actions Bot commented Jun 2, 2026

Copy link
Copy Markdown

These changes were released in v1.221.0-rc.2.

Ben (Benbentwo) pushed a commit to Benbentwo/atmos that referenced this pull request Jun 8, 2026
…s aws ecr login --public` (cloudposse#2231)

* feat: Add aws/ecr-public integration kind for authenticated ECR Public registry access

- Add ECR Public support via new aws/ecr-public integration kind
- Implement region validation (us-east-1 and us-west-2 supported)
- Add cloud layer with GetPublicAuthorizationToken and region validation
- Add integration layer with factory and execution
- Update documentation for ecr-login command and tutorial
- Add blog post announcing feature
- Update roadmap with shipped milestone

Closes cloudposse#2079 (as part of Native CI/CD integration feature)

* [autofix.ci] apply automated fixes

* fix: Address PR review feedback for ECR Public auth (cloudposse#2231)

- Add unit tests for GetPublicAuthorizationToken covering all error/success branches
- Add unit tests for ECRPublicIntegration.Execute happy path and failure branches
- Introduce ECRPublicClient interface with options pattern for testability
- Add injectable dependencies to ECRPublicIntegration for mock-based testing
- Fix missing workspace_id in pro.mdx bearer-token example
- Fix precedence table contradiction in version/use.mdx
- Add pr: 2231 to ECR Public roadmap milestone

Coverage: cloud/aws 81.5%, integrations/aws 87.0% (both above 80% threshold)

Co-Authored-By: Claude Opus 4.6 <[email protected]>

* docs: bump auth initiative roadmap progress to 81%

Co-Authored-By: Claude Opus 4.8 <[email protected]>

* [autocommit] formatting fixes

* chore: gitignore .claude/scheduled_tasks.lock

Runtime lock file from the Claude Code scheduled-tasks system; not source.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

* style: gofumpt ecr_public_test.go

gofumpt v0.10.0 (CI) reformats multi-line mock .Return(...) calls with a
trailing comma and the closing paren on its own line. The local pre-commit
only checks changed files, so this pre-existing test file slipped through;
CI runs gofumpt across the full PR diff and flagged it.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

* feat(aws/ecr): add --public flag for direct ECR Public login

Add `atmos aws ecr login --public` for zero-config ECR Public
(public.ecr.aws) authentication using ambient AWS credentials (the AWS SDK
default chain: env, shared config/profile, SSO, IMDS/IRSA/ECS), or
`--public --identity <name>` to use a specific identity's credentials.
`--public` is mutually exclusive with a positional integration argument and
`--registry`. The `aws/ecr-public` integration kind remains for
auto-provisioning on `atmos auth login`.

- cmd/aws/ecr/login.go: --public flag, ambient + identity login paths, and
  validateLoginModes mode validation; tests in login_test.go.
- Docs/blog/PRD: switch ECR Public examples to `atmos aws ecr login --public`
  and document the flag in the command reference and tutorial.
- Changelog: redate the blog post to 2026-05-30 (filename + frontmatter) and
  align the roadmap milestone quarter to q2-2026.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

* chore(config): use errors.As for ConfigFileNotFoundError

Sync load.go with origin/main's errorlint fix (switch err.(type) ->
errors.As) so the pre-commit linter passes; reconciles cleanly on the
upcoming merge.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

* feat(auth): support interactive identity selection in ecr login

Bare `--identity` on `atmos aws ecr login` (with or without `--public`)
now opens the same interactive identity picker used by `atmos auth login`
instead of erroring out. Resolves the `__SELECT__` sentinel via
`AuthManager.GetDefaultIdentity(true)`, degrading cleanly to
ErrIdentitySelectionRequiresTTY in non-interactive contexts.

Also echo the chosen identity ("Selected identity: <name>") after a
successful interactive pick in promptForIdentity. The huh form clears
itself on submit, so previously the selection vanished and any command
without its own whoami display (exec, shell, env, ecr login) left the
user blind to what was used. Writes to stderr so machine-readable stdout
(e.g. `atmos auth env`) stays uncorrupted.

Removes the now-unused ErrECRIdentitySelect sentinel.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

* test(auth): raise ECR Public login coverage above patch gate

Add unit tests for the ECR Public login paths that were below the 80%
Codecov patch target:

- cmd/aws/ecr: 39.8% -> 87.6%. Introduce package-level function-var
  seams (loadDefaultAWSCredentials, getPublicAuthorizationToken,
  getAuthorizationToken) and make createAuthManager a var, mirroring the
  existing seam pattern in pkg/auth/integrations/aws/ecr.go, so the login
  helpers can be unit-tested with stubs and a mock AuthManager. No
  behavior change.
- pkg/auth/integrations/aws: cover ECRPublicIntegration Cleanup and
  Environment via the existing ecrDockerConfigFactory seam.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

* docs(blog): show ECR Public pull flow and credential location

Document the full "log in then pull directly" path in the ECR Public
changelog post: add the --public --identity variant, a docker pull
example, and a note that credentials are written to the standard Docker
config ($DOCKER_CONFIG or ~/.docker/config.json) so plain docker pull
works without atmos auth exec (tokens last ~12h).

Co-Authored-By: Claude Opus 4.8 <[email protected]>

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 <[email protected]>
Co-authored-by: atmos-pro[bot] <173522224+atmos-pro[bot]@users.noreply.github.com>
Co-authored-by: Andriy Knysh <[email protected]>
Juan A. (jaguer0) added a commit to jaguer0/atmos that referenced this pull request Jul 28, 2026
Add a PRD for native RDS IAM database authentication (`atmos aws rds token`),
following the eks-kubeconfig.md and ecr-public-authentication.md precedent
(H1 title, no YAML front-matter). Documents the Phase 1 "dumb token" command:
two-layer architecture, required --host/--port/--username/--region flags,
data.WriteUnmasked output, the ErrRDSTokenGeneration sentinel, an >=85%
coverage target, and a phased Implementation Checklist. Companion to the EKS
(cloudposse#2149) and ECR Public (cloudposse#2231) auth PRDs.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Juan A. (jaguer0) added a commit to jaguer0/atmos that referenced this pull request Jul 28, 2026
Add a cloud-layer RDS IAM database-authentication token generator so Atmos can
mint short-lived (~15m) SigV4 connection tokens from an Atmos identity without
the AWS CLI, mirroring the EKS exec-credential (cloudposse#2149) and ECR Public
bearer-token (cloudposse#2231) auth paths.

- pkg/auth/cloud/aws/rds.go: GetRDSToken(ctx, creds, endpoint, region, dbUser)
  builds the token via aws-sdk-go-v2 feature/rds/auth BuildAuthToken, with
  credentials resolved from the Atmos identity through the existing
  BuildAWSConfigFromCreds bridge -- never the ambient default chain. Logs
  metadata only (token_length), never the token value.
- errors/errors.go: add static sentinel ErrRDSTokenGeneration beside
  ErrEKSTokenGeneration; SDK failures wrap it with %w for errors.Is.
- go.mod/go.sum: add github.com/aws/aws-sdk-go-v2/feature/rds/auth
  (go mod tidy); NOTICE: add the Apache-2.0 stanza.

Tests: TestGetRDSToken_Success (offline; token contains Action=connect / DBUser
/ X-Amz-Signature and a future ~15m expiry) and TestGetRDSToken_InvalidCredentials
(errors.Is ErrRDSTokenGeneration), written failing-first -- no live RDS call.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Juan A. (jaguer0) added a commit to jaguer0/atmos that referenced this pull request Jul 28, 2026
Add a PRD for native RDS IAM database authentication (`atmos aws rds token`),
following the eks-kubeconfig.md and ecr-public-authentication.md precedent
(H1 title, no YAML front-matter). Documents the Phase 1 "dumb token" command:
two-layer architecture, required --host/--port/--username/--region flags,
data.WriteUnmasked output, the ErrRDSTokenGeneration sentinel, an >=85%
coverage target, and a phased Implementation Checklist. Companion to the EKS
(cloudposse#2149) and ECR Public (cloudposse#2231) auth PRDs.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Juan A. (jaguer0) added a commit to jaguer0/atmos that referenced this pull request Jul 28, 2026
Add a cloud-layer RDS IAM database-authentication token generator so Atmos can
mint short-lived (~15m) SigV4 connection tokens from an Atmos identity without
the AWS CLI, mirroring the EKS exec-credential (cloudposse#2149) and ECR Public
bearer-token (cloudposse#2231) auth paths.

- pkg/auth/cloud/aws/rds.go: GetRDSToken(ctx, creds, endpoint, region, dbUser)
  builds the token via aws-sdk-go-v2 feature/rds/auth BuildAuthToken, with
  credentials resolved from the Atmos identity through the existing
  BuildAWSConfigFromCreds bridge -- never the ambient default chain. Logs
  metadata only (token_length), never the token value.
- errors/errors.go: add static sentinel ErrRDSTokenGeneration beside
  ErrEKSTokenGeneration; SDK failures wrap it with %w for errors.Is.
- go.mod/go.sum: add github.com/aws/aws-sdk-go-v2/feature/rds/auth
  (go mod tidy); NOTICE: add the Apache-2.0 stanza.

Tests: TestGetRDSToken_Success (offline; token contains Action=connect / DBUser
/ X-Amz-Signature and a future ~15m expiry) and TestGetRDSToken_InvalidCredentials
(errors.Is ErrRDSTokenGeneration), written failing-first -- no live RDS call.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

This branch was successfully deployed

1 active deployment
preview — 6a39939a Deployed Jun 2, 2026 by github-actions[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

minor New features that do not break anything size/l Large size PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants