-
Notifications
You must be signed in to change notification settings - Fork 598
Description
Description
The pkg/name package currently interprets shorthand image names like "ubuntu" as
"index.docker.io/library/ubuntu:latest", automatically defaulting missing fields to:
- Registry: index.docker.io
- Repository prefix: library
- Tag: latest
While convenient, this behavior cannot currently be customized. It would be useful to support environments where the default repository prefix differs from "library" (e.g., "default" or "base").
Proposed solution
Add an optional argument or configuration option to let users specify the default repository prefix when parsing references, for example:
ref, err := name.ParseReference("ubuntu", name.WithDefaultRepo("default"))
// -> index.docker.io/default/ubuntu:latest
or via a package-level configuration:
name.SetDefaultRepo("default")
This would maintain backward compatibility (still defaulting to "library") while allowing users to adapt the behavior to custom registries or mirrors.
Motivation
This feature would help:
- Integrate with registries that use different default namespaces.
- Improve flexibility when working in registry setups.
- Maintain consistency with existing configuration patterns in the package (e.g. WithDefaultRegistry).
References
pkg/name documentation
Similar defaulting logic in name.go