jkube icon indicating copy to clipboard operation
jkube copied to clipboard

ImageName should be able to handle Image names when both tag and digest are provided

Open rohanKanojia opened this issue 1 year ago • 3 comments

Component

None

Task description

Description

As described in this comment in ORAS registry/reference.go:

<--- path --------------------------------------------> | - Decode path <=== REPOSITORY ===> <--- reference ------------------> | - Decode reference <=== REPOSITORY ===> @ <=================== digest ===> | - Valid Form A <=== REPOSITORY ===> : <!!! TAG !!!> @ <=== digest ===> | - Valid Form B (tag is dropped) <=== REPOSITORY ===> : <=== TAG ======================> | - Valid Form C <=== REPOSITORY ======================================> | - Valid Form D

When both tag and digest are provided, the tag should be ignored and digest should be used. Currently, ImageName is not able to handle this scenario and throws an exception.

Expected Behavior

ImageName should be able to handle ImageName with both tag and digest (e.g. registry.example.com/hello-world:@sha256:b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9) provided and give precedence to digest.

Acceptance Criteria

  • [ ] ImageName is updated to handle scenarios including both tag and digest

rohanKanojia avatar Jan 11 '24 17:01 rohanKanojia

Hi @rohanKanojia i have a doubt, is IMAGE_NAME_REGEXP = Pattern.compile(NAME_COMPONENT_REGEXP + "(?:(?:/" + NAME_COMPONENT_REGEXP + ")+)?"); correct? because i can see an extra component "domainregexp" in its reference

https://github.com/docker/docker/blob/04da4041757370fb6f85510c8977c5a18ddae380/vendor/github.com/docker/distribution/reference/regexp.go#L53

NameRegexp = expression( optional(DomainRegexp, literal(/)), nameComponentRegexp, optional(repeated(literal(/), nameComponentRegexp)))

Devashishbasu avatar Feb 14 '24 22:02 Devashishbasu

@Devashishbasu : I think this regex only validates the name portion. Could you please check it by setting a breakpoint in doValidate() method and checking if image actually contains registry at during validation. I think registry is already extracted from image name before reaching this path.

rohanKanojia avatar Feb 15 '24 05:02 rohanKanojia

@Devashishbasu : I think this regex only validates the name portion. Could you please check it by setting a breakpoint in doValidate() method and checking if image actually contains registry at during validation. I think registry is already extracted from image name before reaching this path.

yes you are right , registry is already extracted from image name before reaching this path.

Devashishbasu avatar Feb 16 '24 06:02 Devashishbasu