-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix image name parsing with tag and digest #4406
Fix image name parsing with tag and digest #4406
Conversation
Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA. It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
|
Welcome @cronik! |
Hi @cronik. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Image names may contain both tag name and digest. For example `nginx:1.21.5@sha256:7826426c9d8d310c62fc68bcd5e8dde70cb39d4fbbd30eda3b1bd03e35fbde29`. Kustomizations with image transforms will not match these image because the image parser assumes either a tag or digest, but not both. For a real life example of kuberenetes deployments that might need to perform these types of transforms is from the [tekton-pipelines](https://github.com/tektoncd/pipeline) project (see the release.yaml).
678bc0c
to
7a3c426
Compare
I signed it |
/check-cla |
/ok-to-test |
api/image/image.go
Outdated
@@ -24,24 +24,31 @@ func IsImageMatched(s, t string) bool { | |||
func Split(imageName string) (name string, tag string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we change this method to return three things - a name, tag, and digest? Below in one of the tests I see tag: :1.2.3@sha256:12345
which doesn't seem correct. We should differentiate the tag and digest where possible to help support cases where there are both.
api/image/image_test.go
Outdated
testName: "with domain", | ||
value: "docker.io/nginx:1.2.3", | ||
name: "docker.io/nginx", | ||
tag: ":1.2.3", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO it doesn't make sense to include the leading colon in the split. The tag is "1.2.3". Could you change that?
api/image/image_test.go
Outdated
name: "nginx", | ||
tag: "@12345", | ||
tag: "@sha256:12345", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aligned with the above suggestion to change the Split
function to return the tag and digest separately, I'd like to see this test look like the following:
testName: "with digest",
value: "nginx@sha256:12345",
name: "nginx",
digest: "sha256:12345"
@cronik: This PR has multiple commits, and the default merge method is: merge. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
@natasha41575 updated |
image.Split now returns 3 fields: name, tag, and digest. The tag and digest fields no longer include their respective delimiters (`:` and `@`).
286bb9f
to
727093f
Compare
@natasha41575 I had to make a few commit to resolve merge conflicts, may want to add the label |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly looking good, couple of minor comments
/lgtm |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: cronik, natasha41575 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Image names may contain both tag name and digest. For example
nginx:1.21.5@sha256:7826426c9d8d310c62fc68bcd5e8dde70cb39d4fbbd30eda3b1bd03e35fbde29
. Kustomizations with image transforms will not matchthese image because the image parser assumes either a tag or digest, but not
both.
For a real life example of kuberenetes deployments that might need to perform
these types of transforms is from the tekton-pipelines project (see the release.yaml).