Skip to content

Add default repository prefix option#2326

Open
Haihan-Jiang wants to merge 1 commit into
google:mainfrom
Haihan-Jiang:codex/go-containerregistry-default-repo-prefix
Open

Add default repository prefix option#2326
Haihan-Jiang wants to merge 1 commit into
google:mainfrom
Haihan-Jiang:codex/go-containerregistry-default-repo-prefix

Conversation

@Haihan-Jiang

Copy link
Copy Markdown
Contributor

Adds name.WithDefaultRepositoryPrefix so callers can choose the default prefix used for single-component repository names.

The existing behavior stays the same unless the option is set:

  • ubuntu still defaults to index.docker.io/library/ubuntu:latest
  • WithDefaultRegistry(...) still defaults only the registry/tag unless a repository prefix is explicitly provided
  • WithDefaultRepositoryPrefix("base") makes ubuntu parse as index.docker.io/base/ubuntu:latest

Fixes #2145.

Tests:

  • go test ./pkg/name
  • go test ./pkg/name ./pkg/v1/remote/transport
  • git diff --check

@Haihan-Jiang

Copy link
Copy Markdown
Contributor Author

This is ready for review. The default repository prefix option is added, and the visible checks are green.

@codecov-commenter

codecov-commenter commented Jun 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.10345% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 56.97%. Comparing base (31df54c) to head (a0dd82c).
⚠️ Report is 19 commits behind head on main.

Files with missing lines Patch % Lines
pkg/name/repository.go 90.90% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2326      +/-   ##
==========================================
+ Coverage   56.91%   56.97%   +0.05%     
==========================================
  Files         165      165              
  Lines       11362    11382      +20     
==========================================
+ Hits         6467     6485      +18     
- Misses       4134     4135       +1     
- Partials      761      762       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

Allow overriding the default repository prefix when parsing image references in pkg/name

2 participants