Skip to content

registry auth fallback bugfix#672

Merged
amartin120 merged 1 commit into
hauler-dev:mainfrom
amartin120:reg-auth-bug
Jul 21, 2026
Merged

registry auth fallback bugfix#672
amartin120 merged 1 commit into
hauler-dev:mainfrom
amartin120:reg-auth-bug

Conversation

@amartin120

@amartin120 amartin120 commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Please check below, if the PR fulfills these requirements:

  • Commit(s) and code follow the repositories guidelines.
  • Test(s) have been added or updated to support these change(s).
  • Doc(s) have been added or updated to support these change(s).

Associated Links:

Types of Changes:

  • Bugfix

Proposed Changes:

Fixes registry credential resolution during hauler store copy registry://, add, and sync when running in environments without a $HOME or $DOCKER_CONFIG set. hauler login has a fallback for this but go-containerregistry doesn't inherently look in the fallback location.

  • pkg/content/dockerconfig.go (new): Adds SetDefaultDockerConfig(), which defaults $DOCKER_CONFIG to the same directory hauler login writes to (<home>/.docker) so go-containerregistry's DefaultKeychain can find credentials even when $HOME is unset. Replicates docker/cli's config.Dir()/getHomeDir() resolution — including the /etc/passwd fallback via os/user.Current() — using only the standard library. An explicitly set DOCKER_CONFIG always wins.
  • cmd/hauler/cli/cli.go: Invokes SetDefaultDockerConfig() in the root PersistentPreRun, logging the defaulted path at debug level.
  • pkg/content/registry.go: Stops silently swallowing credential-resolution failures. Registry host parse errors, keychain resolve errors, and authorization read errors now return wrapped errors instead of falling back to anonymous auth; only a genuine Anonymous result yields empty credentials.

Verification/Testing of Changes:

  1. With credentials stored via hauler login <registry> and $HOME unset, run hauler store copy registry://<registry>/... and confirm the push authenticates instead of failing anonymously.
  2. Run with --log-level debug and confirm the defaulted $DOCKER_CONFIG to [...] line appears.
  3. Confirm an explicitly set $DOCKER_CONFIG is left unchanged.

Additional Context:

Small, targeted bugfix. The previous code returned anonymous credentials on any resolution error, masking real auth failures; this makes credential lookup match hauler login's write location and surfaces genuine errors.

@github-project-automation github-project-automation Bot moved this to To Triage in Hauler Jul 17, 2026
@amartin120 amartin120 added bug Something isn't working go Pull requests that update go code size/S Denotes an issue/PR requiring a relatively small amount of work labels Jul 18, 2026
Signed-off-by: Adam Martin <adam.martin@ranchergovernment.com>

@atoy3731 atoy3731 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.

LGTM.

@github-project-automation github-project-automation Bot moved this from To Triage to Testing in Hauler Jul 21, 2026
@amartin120
amartin120 merged commit 6f5d767 into hauler-dev:main Jul 21, 2026
3 checks passed
@github-project-automation github-project-automation Bot moved this from Testing to Resolved in Hauler Jul 21, 2026
@amartin120

Copy link
Copy Markdown
Contributor Author

@Mergifyio backport release/2.0

@mergify

mergify Bot commented Jul 21, 2026

Copy link
Copy Markdown

backport release/2.0

✅ Backports have been created

Details

Cherry-pick of 6f5d767 has failed:

On branch mergify/bp/release/2.0/pr-672
Your branch is up to date with 'origin/release/2.0'.

You are currently cherry-picking commit 6f5d767.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	new file:   pkg/content/dockerconfig.go
	modified:   pkg/content/registry.go

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   cmd/hauler/cli/cli.go

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

amartin120 added a commit that referenced this pull request Jul 21, 2026
Signed-off-by: Adam Martin <adam.martin@ranchergovernment.com>
(cherry picked from commit 6f5d767)
amartin120 added a commit that referenced this pull request Jul 21, 2026
Signed-off-by: Adam Martin <adam.martin@ranchergovernment.com>
Co-authored-by: Adam Martin <adam.martin@ranchergovernment.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working go Pull requests that update go code size/S Denotes an issue/PR requiring a relatively small amount of work

Projects

Status: Resolved

Development

Successfully merging this pull request may close these issues.

3 participants