-
Notifications
You must be signed in to change notification settings - Fork 712
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Correctly extract image name when using custom hub.
- Loading branch information
Showing
2 changed files
with
29 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package render | ||
|
||
import ( | ||
"testing" | ||
) | ||
|
||
func TestDockerImageRegexp(t *testing.T) { | ||
for _, input := range []struct{ in, reg, image, ver string }{ | ||
{"foo/bar:baz", "", "foo/bar", "baz"}, | ||
{"reg:123/foo/bar:baz", "reg:123", "foo/bar", "baz"}, | ||
{"docker-registry.domain.name:5000/repo/image1:ver", "docker-registry.domain.name:5000", "repo/image1", "ver"}, | ||
} { | ||
mapping := dockerImageMatch.FindStringSubmatch(input.in) | ||
if mapping == nil { | ||
t.Fatalf("No match: %v", input) | ||
} | ||
if mapping[1] != input.reg || | ||
mapping[2] != input.image || | ||
mapping[3] != input.ver { | ||
t.Fatalf("Bad regexp: %v, %v", mapping, input) | ||
} | ||
} | ||
} |