Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion image/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,10 +306,18 @@ func ParseContainer(pod *v1.Pod, containerName string) (*Image, error) {

// Set tag name
s := strings.Split(container.Image, ":")
if len(s) != 2 && len(s) != 3 {
if len(s) > 3 {
return nil, fmt.Errorf("Wrong image format: %s", container.Image)
}

// If the string after the colon contains a / we
// can assume it's the repository and no tag has been
// defined.
if len(s) == 1 || strings.Contains(s[len(s)-1], "/") {
image.Tag = "latest"
return image, nil
}

tagname := s[len(s)-1]
if len(tagname) == 0 {
return nil, fmt.Errorf("Empty Tag")
Expand Down
36 changes: 36 additions & 0 deletions image/image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,42 @@ var containerStatusTable = []struct {

expectedError error
}{
{
"my-test-repository",
"QUAY:443/my-test-namespace/my-test-repository",
"docker-pullable://QUAY:443/my-test-namespace/my-test-repository@sha256:c549c6151dd8f4098fd02198913c0f6c55b240b156475588257f19d57e7b1fba",
"my-test-repository",
"QUAY:443",
"my-test-namespace",
"my-test-repository",
"sha256:c549c6151dd8f4098fd02198913c0f6c55b240b156475588257f19d57e7b1fba",
"latest",
nil,
},
{
"my-test-repository",
"quay.io/my-test-namespace/my-test-repository",
"docker-pullable://quay.io/my-test-namespace/my-test-repository@sha256:c549c6151dd8f4098fd02198913c0f6c55b240b156475588257f19d57e7b1fba",
"my-test-repository",
"quay.io",
"my-test-namespace",
"my-test-repository",
"sha256:c549c6151dd8f4098fd02198913c0f6c55b240b156475588257f19d57e7b1fba",
"latest",
nil,
},
{
"redis",
"redis",
"docker-pullable://redis@sha256:c549c6151dd8f4098fd02198913c0f6c55b240b156475588257f19d57e7b1fba",
"redis",
"docker.io",
"library",
"redis",
"sha256:c549c6151dd8f4098fd02198913c0f6c55b240b156475588257f19d57e7b1fba",
"latest",
nil,
},
{
"my-test-repository",
"QUAY:443/my-test-namespace/my-test-repository@sha256:c549c6151dd8f4098fd02198913c0f6c55b240b156475588257f19d57e7b1fba",
Expand Down