Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@thaJeztah
Copy link
Member

@thaJeztah thaJeztah commented Dec 10, 2018

This copies the NormalizeImageRef utility function that was added in containerd/cri https://github.com/containerd/cri/blob/0e42438e7a157f6aec41cd808a85bc883d646ff3/pkg/util/image.go#L23-L50

Reason for this PR is that starting with containerd/containerd@bce20b7 (containerd/containerd#2633), containerd now adds containerd/cri as a new dependency when vendoring in docker/cli (because of this utility which is mainly a small wrapper for other functions in docker/distribution);

Building statically linked build/docker-linux-amd64
vendor/github.com/containerd/containerd/images/archive/reference.go:22:2: cannot find package "github.com/containerd/cri/pkg/util" in any of:
	/go/src/github.com/docker/cli/vendor/github.com/containerd/cri/pkg/util (vendor tree)
	/usr/local/go/src/github.com/containerd/cri/pkg/util (from $GOROOT)
	/go/src/github.com/containerd/cri/pkg/util (from $GOPATH)
make: *** [binary] Error 1

If this patch is accepted, I'll open a PR in containerd/cri to remove the utility there.

ParseDockerRef normalizes the image reference following the docker
convention. This is added mainly for backward compatibility. The reference
returned can only be either tagged or digested. For reference contains both tag
and digest, the function returns digested reference, e.g.

docker.io/library/busybox:latest@sha256:7cc4b5aefd1d0cadf8d97d4350462ba51c694ebca145b08d7d41b41acc8db5aa

will be returned as

docker.io/library/busybox@sha256:7cc4b5aefd1d0cadf8d97d4350462ba51c694ebca145b08d7d41b41acc8db5aa.

@thaJeztah thaJeztah requested a review from dmcgowan December 10, 2018 23:00
@thaJeztah
Copy link
Member Author

ping @dmcgowan @Random-Liu PTAL

(I'm open to better suggestions if we don't want to add this utility here)

@thaJeztah thaJeztah force-pushed the add_normalize_util branch 2 times, most recently from 09ff6ed to 0f3ff4a Compare December 11, 2018 09:19
@thaJeztah
Copy link
Member Author

Updated; also slightly rewrite the test to use subtests. PTAL

@codecov
Copy link

codecov bot commented Dec 11, 2018

Codecov Report

Merging #2786 into master will increase coverage by 0.13%.
The diff coverage is 57.14%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2786      +/-   ##
==========================================
+ Coverage   60.24%   60.37%   +0.13%     
==========================================
  Files         103      103              
  Lines        8022     8036      +14     
==========================================
+ Hits         4833     4852      +19     
+ Misses       2546     2537       -9     
- Partials      643      647       +4
Flag Coverage Δ
#linux 60.37% <57.14%> (+0.13%) ⬆️
Impacted Files Coverage Δ
reference/normalize.go 82.02% <57.14%> (+2.02%) ⬆️
reference/helpers.go 89.47% <0%> (+31.57%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 40b7b58...0ac367f. Read the comment docs.

@thaJeztah thaJeztah changed the title Add reference.NormalizeImageRef utility function Add reference. ParseDockerRef utility function Dec 11, 2018
@thaJeztah
Copy link
Member Author

@dmcgowan nudge 🤗

@dmcgowan
Copy link
Collaborator

dmcgowan commented Jan 4, 2019

LGTM after small typo fix in test

ParseDockerRef normalizes the image reference following the docker
convention. This is added mainly for backward compatibility. The reference
returned can only be either tagged or digested. For reference contains both tag
and digest, the function returns digested reference, e.g.

    docker.io/library/busybox:latest@sha256:7cc4b5aefd1d0cadf8d97d4350462ba51c694ebca145b08d7d41b41acc8db5aa

will be returned as

    docker.io/library/busybox@sha256:7cc4b5aefd1d0cadf8d97d4350462ba51c694ebca145b08d7d41b41acc8db5aa.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
@thaJeztah
Copy link
Member Author

ping @dmcgowan @caervs ptal 🤗

Copy link
Contributor

@caervs caervs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants