Skip to content

Commit cd4bb74

Browse files
authored
Merge pull request #7054 from dkoshkin/fix-kuber-proxy-update-with-docker.io-image
🐛 Fix kube-proxy upgrade with docker.io image
2 parents e2bb351 + 74272a0 commit cd4bb74

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

util/container/image.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ func ModifyImageTag(imageName, tagName string) (string, error) {
121121
return "", errors.Wrap(err, "failed to update image tag")
122122
}
123123

124-
return reference.FamiliarString(reference.TagNameOnly(namedTagged)), nil
124+
return reference.TagNameOnly(namedTagged).String(), nil
125125
}
126126

127127
// ImageTagIsValid ensures that a given image tag is compliant with the OCI spec.

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)