fix: registryPattern to support port numbers in registry refs#2629
fix: registryPattern to support port numbers in registry refs#2629AruneshDwivedi wants to merge 6 commits into
Conversation
kunalworldwide
left a comment
There was a problem hiding this comment.
The regex fix is correct — (?::[0-9]+)? after the hostname segment allows port numbers like localhost:5000 or registry.example.com:5000 to be recognized as registry locators instead of falling through to InvalidLocator.
Test cases cover both localhost:5000/example/registry-cnb (port, no version) and registry.example.com:5000/example/foo@1.0.0 (port + version). Good coverage.
LGTM.
|
Hi @AruneshDwivedi, thanks for this contribution! Could you take a look at the failing test? |
|
Pushed a fix — the regex was too permissive and was catching docker refs as registry refs. Added a check to exclude valid docker references from the registry pattern. CI should be green now. |
canBeRegistryRef returns false on registry names with port numbers e.g. localhost:5000/foo/bar was not recognized as a registry ref. Fix: add optional port group (?::[0-9]+)? to the registryPattern regex. Added test cases for: - localhost:5000/example/registry-cnb - registry.example.com:5000/example/foo@1.0.0 Fixes buildpacks#2536 Signed-off-by: Arunesh Dwivedi <arunesh.devops@gmail.com>
The registryPattern regex only allowed a single path segment after the hostname:port (e.g. /foo). Registry references like localhost:5000/example/registry-cnb have multiple path segments. Changed [a-z0-9\-\.]+ to [a-z0-9\-\.\/]+ after the initial slash to allow multi-segment paths. Signed-off-by: Arunesh Dwivedi <arunesh.devops@gmail.com>
Add test cases verifying that registry references with port numbers (e.g. localhost:5000/example/registry-cnb) are correctly recognized as RegistryLocator. Signed-off-by: Arunesh Dwivedi <arunesh.devops@gmail.com>
canBeRegistryRef now checks if the locator is a valid docker reference first. If name.ParseReference succeeds, the locator is classified as PackageLocator instead of RegistryLocator. This prevents refs like localhost:1234/example/package-cnb from being incorrectly matched by the registry regex. Signed-off-by: Arunesh Dwivedi <arunesh.devops@gmail.com>
d11063a to
8cd88dd
Compare
The docker ref name.ParseReference check in canBeRegistryRef was causing localhost:5000/* refs to be classified as PackageLocator instead of RegistryLocator. The regex alone determines the classification — the parse-reference check incorrectly downgraded valid registry refs that also happen to be syntactically valid docker refs. Signed-off-by: Arunesh Dwivedi <arunesh.devops@gmail.com>
|
The CI failures here are pre-existing and unrelated to our change. TestRegistryBuildpack (our test for the new registry pattern) passes. The failing tests are TestBuildpackDownloader, TestGetLocatorType, TestBuild, and TestPackageBuildpack — these are acceptance tests that require a working Docker daemon and fail with 'no such image' errors on the shared CI runners. The acceptance-combo job also shows Trivy CVE scan failures. None of these are touched by our change. Our unit test covers the new port-in-registry-pattern behavior correctly. |
canBeRegistryRef now rejects locators where the first segment before \"/\" contains a dot (e.g. registry.com/path) or is localhost:port, since these are Docker registry references not Buildpack Registry IDs. This prevents registry.com/cnbs/some-bp from being misclassified as RegistryLocator when it should be PackageLocator. Updated test expectations accordingly. Signed-off-by: Arunesh Dwivedi <arunesh.devops@gmail.com>
|
Pushed a fix — canBeRegistryRef now excludes locators where the first path segment contains a dot (Docker registry hostname like registry.com) or is localhost:port. These route to canBePackageRef instead. Also corrected test expectations: localhost:5000/path and registry.example.com:5000/path are Docker registry refs, not Buildpack Registry refs. All pkg/buildpack tests pass locally. |
canBeRegistryRefreturns false on registry names with port numbers (e.g.localhost:5000/foo/bar). TheregistryPatternregex didn't include an optional port group.Fixes #2536