Skip to content

Treat Docker Hub's library namespace as implicit in ComparisonForm - #72

Open
charlie-morrison wants to merge 1 commit into
git-pkgs:mainfrom
charlie-morrison:docker-library-comparison
Open

charlie-morrison wants to merge 1 commit into
git-pkgs:mainfrom
charlie-morrison:docker-library-comparison

Conversation

@charlie-morrison

Copy link
Copy Markdown
Contributor

Fixes #70.

ComparisonForm now has a docker rule. A library namespace is dropped when the purl has no repository_url qualifier, so pkg:docker/python@3.12 and pkg:docker/library/python@3.12 both compare as pkg:docker/python@3.12. With a repository_url the image is on another registry, where Docker Hub's implicit namespace doesn't apply, so the namespace stays. Parse and String are unchanged, and the doc comment lists the new rule next to the others.

What I left alone: other namespaces (bitnami/python), a nested library/library/python, and a repository_url that points at Docker Hub itself (docker.io). That last one compares differently from a bare purl anyway, because the qualifier is part of the form.

Tests:

  • TestComparisonForm has six docker rows: with and without library, a digest version with a qualifier, a repository_url, another namespace, and the nested case. The two rows that should lose library fail on main.
  • TestComparisonFormEquivalentSpellings has the issue's pair, and TestComparisonFormLeavesParseAlone checks that String() still keeps library/.
  • Two mutants fail the tests: dropping any namespace instead of only library, and ignoring repository_url.
  • go test ./... (with testdata/purl-spec at the pinned commit), go vet, gofmt and golangci-lint (0 issues) are clean.

Docker Hub official images live under an implicit "library" namespace,
so pkg:docker/python and pkg:docker/library/python name one image but
had different comparison forms. ComparisonForm now drops a "library"
namespace for docker purls with no repository_url qualifier. With a
repository_url the image is on another registry, where the rule does
not apply, so the namespace stays.

Fixes git-pkgs#70

Co-authored-by: Claude <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Dec 6, 2026

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 208747b3-4587-438b-b7c4-47e1ee7015fd
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

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.

ComparisonForm treats pkg:docker/python and pkg:docker/library/python as different

1 participant