-
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
Changes from 1 commit
7a3c426
727093f
a62a229
1bac439
11d585e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,11 +23,23 @@ func TestIsImageMatched(t *testing.T) { | |
isMatched: true, | ||
}, | ||
{ | ||
testName: "name is match", | ||
testName: "name is match with tag", | ||
value: "nginx:12345", | ||
name: "nginx", | ||
isMatched: true, | ||
}, | ||
{ | ||
testName: "name is match with digest", | ||
value: "nginx@sha256:xyz", | ||
name: "nginx", | ||
isMatched: true, | ||
}, | ||
{ | ||
testName: "name is match with tag and digest", | ||
value: "nginx:12345@sha256:xyz", | ||
name: "nginx", | ||
isMatched: true, | ||
}, | ||
{ | ||
testName: "name is not a match", | ||
value: "apache:12345", | ||
|
@@ -64,9 +76,27 @@ func TestSplit(t *testing.T) { | |
}, | ||
{ | ||
testName: "with digest", | ||
value: "nginx@12345", | ||
value: "nginx@sha256:12345", | ||
name: "nginx", | ||
tag: "@12345", | ||
tag: "@sha256:12345", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Aligned with the above suggestion to change the
|
||
}, | ||
{ | ||
testName: "with tag and digest", | ||
value: "nginx:1.2.3@sha256:12345", | ||
name: "nginx", | ||
tag: ":1.2.3@sha256:12345", | ||
}, | ||
{ | ||
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 commentThe 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? |
||
}, | ||
{ | ||
testName: "with domain and port", | ||
value: "foo.com:443/nginx:1.2.3", | ||
name: "foo.com:443/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.
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.