Skip to content

fix: don't treat image namespace as registry#755

Merged
buchdag merged 3 commits into
nginx-proxy:mainfrom
JamBalaya56562:fix/154-image-registry
Jul 13, 2026
Merged

fix: don't treat image namespace as registry#755
buchdag merged 3 commits into
nginx-proxy:mainfrom
JamBalaya56562:fix/154-image-registry

Conversation

@JamBalaya56562

@JamBalaya56562 JamBalaya56562 commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Problem

SplitDockerImage treats everything before the first / as the registry. For Docker Hub images that use a namespace/user prefix — e.g. tianon/centos — this incorrectly yields Registry="tianon", Repository="centos" instead of Registry="" (implicit Docker Hub) and Repository="tianon/centos".

Per Docker's reference parser, the first path component is a registry only when it contains a . or :, or is exactly localhost. Otherwise it belongs to the repository path.

Change

SplitDockerImage now applies that rule: the first segment is treated as the registry only when it contains ./: or equals localhost; otherwise the whole user/image is kept as the repository. Tag parsing is unchanged.

Because DockerImage.String() rejoins registry + "/" + repository, the full image string still round-trips — only the split .Image.Registry / .Image.Repository fields change, which is the intended correction for templates that read those fields.

Tests

Added tianon/centos and tianon/centos:7 cases. All existing cases (ubuntu, custom.registry/…, localhost:8888/…, etc.) still pass. No new dependencies.

Fixes #154

🤖 Generated with Claude Code

@JamBalaya56562 JamBalaya56562 force-pushed the fix/154-image-registry branch from 44e0830 to 6175bcd Compare July 11, 2026 19:57
@buchdag

buchdag commented Jul 12, 2026

Copy link
Copy Markdown
Member

@JamBalaya56562 please flag AI-generated PR explicitly in the PR description (ie "🤖 Generated with Claude Code" like in this PR) and add the AI agent as co-author of the commits.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@JamBalaya56562 JamBalaya56562 force-pushed the fix/154-image-registry branch from 6175bcd to b1946dc Compare July 12, 2026 22:38
@JamBalaya56562

Copy link
Copy Markdown
Contributor Author

Done — added the Co-Authored-By: Claude Opus 4.8 trailer to the commit and the 🤖 Generated with [Claude Code](https://claude.com/claude-code) note to the PR description. I also rebased onto the latest main. Thanks for the review!

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This pull request corrects SplitDockerImage so Docker Hub namespaced images like user/repo are no longer misparsed as having a registry, aligning parsing with Docker’s reference rules.

Changes:

  • Treat the first path segment as a registry only when it contains . or :, or equals localhost.
  • Keep tag parsing behavior the same while adjusting how registry/repository are split.
  • Add test cases covering Docker Hub namespaced images (tianon/centos with and without a tag).

Reviewed changes

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

File Description
internal/dockerclient/docker_cli.go Updates image-splitting logic to distinguish registries from Docker Hub namespaces.
internal/dockerclient/docker_cli_test.go Adds coverage for namespaced Docker Hub images and round-trip stringification.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/dockerclient/docker_cli_test.go Outdated
JamBalaya56562 and others added 2 commits July 13, 2026 08:19
Add a test for the `first == "localhost"` branch of SplitDockerImage,
covering the Docker-reference edge case where a bare `localhost` (no port,
no dot) is treated as an explicit registry.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@buchdag buchdag merged commit acd136c into nginx-proxy:main Jul 13, 2026
6 checks passed
@buchdag buchdag added the bug label Jul 13, 2026
@JamBalaya56562 JamBalaya56562 deleted the fix/154-image-registry branch July 13, 2026 10:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docker-gen incorrectly parses the user name part of the Docker image as the registry

3 participants