Skip to content

fix(buildpack): allow port numbers in registry reference URIs#2625

Open
AruneshDwivedi wants to merge 3 commits into
buildpacks:mainfrom
AruneshDwivedi:fix/registry-ref-port-yank-template
Open

fix(buildpack): allow port numbers in registry reference URIs#2625
AruneshDwivedi wants to merge 3 commits into
buildpacks:mainfrom
AruneshDwivedi:fix/registry-ref-port-yank-template

Conversation

@AruneshDwivedi

Copy link
Copy Markdown

Summary

Fixes #2536. The canBeRegistryRef regex pattern didn't allow port numbers in registry hostnames. URIs like docker://localhost:5000/foo/bar were incorrectly rejected.

Root Cause

The registryPattern regex at pkg/buildpack/locator_type.go:39 didn't include an optional port component after the hostname.

Fix

Added (?::\\d+)? to the host portion of the regex pattern to allow optional port numbers.

Testing

The pattern now matches registry references with port numbers (e.g., localhost:5000/foo/bar) in addition to existing patterns without ports.

@AruneshDwivedi AruneshDwivedi requested review from a team as code owners June 8, 2026 09:01
@github-actions github-actions Bot added this to the 0.41.0 milestone Jun 8, 2026
@github-actions github-actions Bot added the type/enhancement Issue that requests a new feature or improvement. label Jun 8, 2026
The canBeRegistryRef regex pattern didn't allow port numbers in registry
hostnames (e.g., localhost:5000/foo/bar). Added optional :\d+ to the
host portion of the pattern.

Fixes buildpacks#2536

Signed-off-by: Arunesh Dwivedi <arunesh.devops@gmail.com>
Assisted-by: OWL
Signed-off-by: Arunesh Dwivedi <arunesh.devops@gmail.com>
@AruneshDwivedi AruneshDwivedi force-pushed the fix/registry-ref-port-yank-template branch from 81283f0 to d644f32 Compare June 8, 2026 13:03
The canBeRegistryRef regex pattern didn't allow port numbers in registry
hostnames (e.g., localhost:5000/foo/bar). Added optional :\d+ to the
host portion of the pattern.

Also updated the namespace validation in registry index to allow ':'
characters for port numbers, while keeping name validation strict.

Fixes buildpacks#2536

Signed-off-by: Arunesh Dwivedi <arunesh.devops@gmail.com>
Assisted-by: OWL
Signed-off-by: Arunesh Dwivedi <arunesh.devops@gmail.com>
…ferences

When a Docker image reference like 'docker://localhost:5000/foo/bar' is
passed to GetLocatorType, the code was calling name.ParseReference with the
full URI including the docker:// prefix. The go-containerregistry library
doesn't understand the docker:// prefix — it expects just the image name
like 'localhost:5000/foo/bar'.

Fix: Call ParsePackageLocator to strip the docker:// prefix before passing
to name.ParseReference.

Fixes buildpacks#2536

Signed-off-by: Arunesh Dwivedi <arunesh.devops@gmail.com>
Assisted-by: OWL
Signed-off-by: Arunesh Dwivedi <arunesh.devops@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type/enhancement Issue that requests a new feature or improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

canBeRegistryRef returns falso on registry names with port numbers

1 participant