Skip to content

Commit

Permalink
fixed docker image canonical names detection
Browse files Browse the repository at this point in the history
  • Loading branch information
hellt committed Apr 15, 2021
1 parent bedac12 commit 97613e2
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion clab/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ func (c *CLab) PullImageIfRequired(ctx context.Context, imageName string) error
// might need canonical name e.g.
// -> alpine == docker.io/library/alpine
// -> foo/bar == docker.io/foo/bar
// -> foo.bar/baz == foo.bar/bar
// -> docker.elastic.co/elasticsearch/elasticsearch == docker.elastic.co/elasticsearch/elasticsearch
canonicalImageName := imageName
slashCount := strings.Count(imageName, "/")
Expand All @@ -270,7 +271,14 @@ func (c *CLab) PullImageIfRequired(ctx context.Context, imageName string) error
case 0:
canonicalImageName = "docker.io/library/" + imageName
case 1:
canonicalImageName = "docker.io/" + imageName
// split on slash to get first element of the name
nameSplit := strings.Split(imageName, "/")
// case of foo.bar/baz
if strings.Contains(nameSplit[0], ".") {
canonicalImageName = imageName
} else {
canonicalImageName = "docker.io/" + imageName
}
}

log.Infof("Pulling %s Docker image", canonicalImageName)
Expand Down

0 comments on commit 97613e2

Please sign in to comment.