Browse Source

Merge pull request #32539 from aaronlehmann/tag-hex-string

client: Allow hex strings as source references for ImageTag
Vincent Demeester 8 years ago
parent
commit
6672ffa566
2 changed files with 12 additions and 1 deletions
  1. 1 1
      client/image_tag.go
  2. 11 0
      client/image_tag_test.go

+ 1 - 1
client/image_tag.go

@@ -10,7 +10,7 @@ import (
 
 
 // ImageTag tags an image in the docker host
 // ImageTag tags an image in the docker host
 func (cli *Client) ImageTag(ctx context.Context, source, target string) error {
 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)
 		return errors.Wrapf(err, "Error parsing reference: %q is not a valid repository/tag", source)
 	}
 	}
 
 

+ 11 - 0
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) {
 func TestImageTag(t *testing.T) {
 	expectedURL := "/images/image_id/tag"
 	expectedURL := "/images/image_id/tag"
 	tagCases := []struct {
 	tagCases := []struct {