Skip to content

Commit 0fd85f3

Browse files
committed
Add a failing test for a valid kube-proxy image from docker.io
1 parent 90923e7 commit 0fd85f3

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

util/container/image_test.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,22 @@ func TestParseImageName(t *testing.T) {
120120
tag: "",
121121
wantError: true,
122122
},
123+
{
124+
name: "input with a docker.io/ image name",
125+
input: "docker.io/dev/kube-proxy:v1.99.99",
126+
repo: "docker.io/dev",
127+
imageName: "kube-proxy",
128+
tag: "v1.99.99",
129+
wantError: false,
130+
},
131+
{
132+
name: "input with a docker.io/ image name that is not canonical",
133+
input: "dev/kube-proxy:v1.99.99",
134+
repo: "dev",
135+
imageName: "kube-proxy",
136+
tag: "v1.99.99",
137+
wantError: true,
138+
},
123139
}
124140
for _, tc := range testCases {
125141
g := NewWithT(t)
@@ -217,4 +233,11 @@ func TestModifyImageTag(t *testing.T) {
217233
g.Expect(err).NotTo(HaveOccurred())
218234
g.Expect(res).To(Equal("example.com/image:v1.17.4_build1"))
219235
})
236+
t.Run("should ensure image is a docker compatible tag with docker.io", func(t *testing.T) {
237+
testTag := "v1.17.4+build1"
238+
image := "docker.io/dev/image:1.17.3"
239+
res, err := ModifyImageTag(image, testTag)
240+
g.Expect(err).NotTo(HaveOccurred())
241+
g.Expect(res).To(Equal("docker.io/dev/image:v1.17.4_build1"))
242+
})
220243
}

0 commit comments

Comments
 (0)