summaryrefslogtreecommitdiff
path: root/client/image_tag.go
diff options
context:
space:
mode:
authorwefine <wang.xiaoren@zte.com.cn>2017-01-03 23:02:58 +0800
committerwefine <wang.xiaoren@zte.com.cn>2017-01-07 04:55:53 +0800
commita041697cabb934e875a1e7f8adea15495209b347 (patch)
tree62fdd8efb392218fdb327d6586326069ae55a3ff /client/image_tag.go
parent10eee3dfa7808f8b252fa6a998fc033bd5fd0c83 (diff)
downloaddocker-a041697cabb934e875a1e7f8adea15495209b347.tar.gz
check both source_image_tag and target_image_tag for 'docker image tag'
Signed-off-by: wefine <wang.xiaoren@zte.com.cn>
Diffstat (limited to 'client/image_tag.go')
-rw-r--r--client/image_tag.go18
1 files changed, 10 insertions, 8 deletions
diff --git a/client/image_tag.go b/client/image_tag.go
index bdbf94add2..dbcd078e1c 100644
--- a/client/image_tag.go
+++ b/client/image_tag.go
@@ -1,21 +1,23 @@
package client
import (
- "errors"
- "fmt"
"net/url"
- "golang.org/x/net/context"
-
distreference "github.com/docker/distribution/reference"
"github.com/docker/docker/api/types/reference"
+ "github.com/pkg/errors"
+ "golang.org/x/net/context"
)
// ImageTag tags an image in the docker host
-func (cli *Client) ImageTag(ctx context.Context, imageID, ref string) error {
- distributionRef, err := distreference.ParseNamed(ref)
+func (cli *Client) ImageTag(ctx context.Context, source, target string) error {
+ if _, err := distreference.ParseNamed(source); err != nil {
+ return errors.Wrapf(err, "Error parsing reference: %q is not a valid repository/tag", source)
+ }
+
+ distributionRef, err := distreference.ParseNamed(target)
if err != nil {
- return fmt.Errorf("Error parsing reference: %q is not a valid repository/tag", ref)
+ return errors.Wrapf(err, "Error parsing reference: %q is not a valid repository/tag", target)
}
if _, isCanonical := distributionRef.(distreference.Canonical); isCanonical {
@@ -28,7 +30,7 @@ func (cli *Client) ImageTag(ctx context.Context, imageID, ref string) error {
query.Set("repo", distributionRef.Name())
query.Set("tag", tag)
- resp, err := cli.post(ctx, "/images/"+imageID+"/tag", query, nil, nil)
+ resp, err := cli.post(ctx, "/images/"+source+"/tag", query, nil, nil)
ensureReaderClosed(resp)
return err
}