fix: don't treat image namespace as registry#755
Conversation
44e0830 to
6175bcd
Compare
|
@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>
6175bcd to
b1946dc
Compare
|
Done — added the |
There was a problem hiding this comment.
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 equalslocalhost. - Keep tag parsing behavior the same while adjusting how
registry/repositoryare split. - Add test cases covering Docker Hub namespaced images (
tianon/centoswith 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.
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>
Problem
SplitDockerImagetreats everything before the first/as the registry. For Docker Hub images that use a namespace/user prefix — e.g.tianon/centos— this incorrectly yieldsRegistry="tianon",Repository="centos"instead ofRegistry=""(implicit Docker Hub) andRepository="tianon/centos".Per Docker's reference parser, the first path component is a registry only when it contains a
.or:, or is exactlylocalhost. Otherwise it belongs to the repository path.Change
SplitDockerImagenow applies that rule: the first segment is treated as the registry only when it contains./:or equalslocalhost; otherwise the wholeuser/imageis kept as the repository. Tag parsing is unchanged.Because
DockerImage.String()rejoinsregistry + "/" + repository, the full image string still round-trips — only the split.Image.Registry/.Image.Repositoryfields change, which is the intended correction for templates that read those fields.Tests
Added
tianon/centosandtianon/centos:7cases. All existing cases (ubuntu,custom.registry/…,localhost:8888/…, etc.) still pass. No new dependencies.Fixes #154
🤖 Generated with Claude Code