Implement configurable default namespace for model references#3
Draft
Implement configurable default namespace for model references#3
Conversation
Co-authored-by: ericcurtin <1694275+ericcurtin@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Implement as ekcasey described here:
@docker/model-distribution/pull/126
"I think the easiest way to get the behavior we want without causing inconsistencies would be set the default namespace for the parsing library to use or supply a WithDefaultNam...
Implement configurable default namespace for model references
Sep 4, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR implements configurable default namespace support for container registry references in the model-distribution system, addressing the issue described in docker#126.
Problem
Currently, the system uses
github.com/google/go-containerregistry/pkg/namepackage directly, which defaults to Docker Hub (index.docker.io) for references without explicit registry hostnames. The upstream library doesn't provide a configurable default namespace option, making it difficult to use alternative default registries for model distribution.Solution
This PR introduces a new
internal/namingpackage that wraps the upstream parsing functions with configurable default namespace support. The implementation:mymodel:latest) and registry ports (localhost:5000/model)Key Changes
New Naming Package
DefaultNamespacestruct with configurable registryParseReference()andParseTag()wrapper methods with smart registry detectionRegistry Client Enhancement
Distribution Client Enhancement
CLI Tool Enhancement
Behavior Examples
mymodel:latestregistry.example.comregistry.example.com/mymodel:latestuser/mymodel:latestregistry.example.comregistry.example.com/user/mymodel:latestother.registry.com/model:latestregistry.example.comother.registry.com/model:latest(preserved)mymodel:latestindex.docker.io/library/mymodel:latest(Docker Hub default)Registry Detection Logic
The package uses heuristics to detect explicit registries:
mymodel:latest→ No explicit registry (:latestis a tag)registry.com/mymodel:latest→ Has explicit registry (contains dot)localhost:5000/mymodel:latest→ Has explicit registry (port number)Integration Points
All reference parsing throughout the codebase now consistently uses the configurable namespace:
Model,BlobURL,BearerToken,NewTarget)Tag,UnTag,HasTag,MatchesReference)Testing
Added comprehensive test coverage including:
This change provides the exact functionality requested in docker#126 - a way to configure default namespaces without requiring upstream changes to go-containerregistry.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.