Skip to content

canBeRegistryRef returns falso on registry names with port numbers #2536

@MikeMoore63

Description

@MikeMoore63

Summary

When you use uri's for locations for docker with registries e.g.

uri = docker://localhost:5000/foo/bar

These are considered invalid uri's uris iwthout ports work perfectly.

Expected behavior

To be able to use uri's with ports

Root cause appears to be this regexp https://github.com/buildpacks/pack/blob/main/pkg/buildpack/locator_type.go#L39

var (
	// https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
	semverPattern   = `(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?`
	registryPattern = regexp.MustCompile(`^[a-z0-9\-\.]+\/[a-z0-9\-\.]+(?:@` + semverPattern + `)?$`)
)

The registryPattern does not match as does not consider ports this simple change to the regexp resolves this ISSUE

var (
	// https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
	semverPattern   = `(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?`
	registryPattern = regexp.MustCompile(`^[a-z0-9\-\.]+(?:|:[0-9]+)\/[a-z0-9\-\.]+(?:@` + semverPattern + `)?$`)
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueA good first issue to get started with.status/readyIssue ready to be worked on.type/bugIssue that reports an unexpected behaviour.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions