diff options
author | Aaron Lehmann <aaron.lehmann@docker.com> | 2017-04-11 13:37:04 -0700 |
---|---|---|
committer | Victor Vieux <victorvieux@gmail.com> | 2017-04-25 16:41:30 -0700 |
commit | aea00bf675444ce9f1bace2999a5487be75b4a5c (patch) | |
tree | d929f9dc1ae71b34e84fcad667d5910c73c19bdf | |
parent | 7e06704af9adb982bc1fd30c4297dea8c98774c9 (diff) | |
download | docker-aea00bf675444ce9f1bace2999a5487be75b4a5c.tar.gz |
client: Allow hex strings as source references for ImageTag
The source of a tag operation is allowed to be a 64-character hex
string. This means it should use ParseAnyReference for validation
instead of ParseNormalizedNamed.
This fixes a regression that happened in 17.04.
Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
(cherry picked from commit 4a0704cdbd1805d0d9ef046eb62a77352f1feab0)
Signed-off-by: Victor Vieux <victorvieux@gmail.com>
-rw-r--r-- | client/image_tag.go | 2 | ||||
-rw-r--r-- | client/image_tag_test.go | 11 |
2 files changed, 12 insertions, 1 deletions
diff --git a/client/image_tag.go b/client/image_tag.go index 35abe332bf..8924f71eb3 100644 --- a/client/image_tag.go +++ b/client/image_tag.go @@ -10,7 +10,7 @@ import ( // ImageTag tags an image in the docker host func (cli *Client) ImageTag(ctx context.Context, source, target string) error { - if _, err := reference.ParseNormalizedNamed(source); err != nil { + if _, err := reference.ParseAnyReference(source); err != nil { return errors.Wrapf(err, "Error parsing reference: %q is not a valid repository/tag", source) } diff --git a/client/image_tag_test.go b/client/image_tag_test.go index 52c5e873a5..f7a0ee331c 100644 --- a/client/image_tag_test.go +++ b/client/image_tag_test.go @@ -46,6 +46,17 @@ func TestImageTagInvalidSourceImageName(t *testing.T) { } } +func TestImageTagHexSource(t *testing.T) { + client := &Client{ + client: newMockClient(errorMock(http.StatusOK, "OK")), + } + + err := client.ImageTag(context.Background(), "0d409d33b27e47423b049f7f863faa08655a8c901749c2b25b93ca67d01a470d", "repo:tag") + if err != nil { + t.Fatalf("got error: %v", err) + } +} + func TestImageTag(t *testing.T) { expectedURL := "/images/image_id/tag" tagCases := []struct { |