From 24082f1d5c6b0919daca944611b9770c9af08e12 Mon Sep 17 00:00:00 2001 From: Denis Parchenko Date: Wed, 25 Nov 2015 17:55:12 +0200 Subject: [PATCH] Add option to replace existing matched image tags --- DOCS.md | 1 + main.go | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/DOCS.md b/DOCS.md index e6bc354..8e74b6f 100644 --- a/DOCS.md +++ b/DOCS.md @@ -7,6 +7,7 @@ The following parameters are used to configure this plugin: * `email` - authenticates with this email * `repo` - repository name for the image * `tag` - repository tag for the image +* `force_tag` - replace existing matched image tags * `insecure` - enable insecure communication to this registry * `mirror` - use a mirror registry instead of pulling images directly from the central Hub * `storage_driver` - use `aufs`, `devicemapper`, `btrfs` or `overlay` driver diff --git a/main.go b/main.go index 84944ec..fd4926c 100644 --- a/main.go +++ b/main.go @@ -29,6 +29,7 @@ type Docker struct { Email string `json:"email"` Auth string `json:"auth"` Repo string `json:"repo"` + ForceTag bool `json:"force_tag"` Tag StrSlice `json:"tag"` File string `json:"file"` Context string `json:"context"` @@ -183,7 +184,11 @@ func main() { // Creates image tags for _, tag := range vargs.Tag.Slice()[1:] { name_ := fmt.Sprintf("%s:%s", vargs.Repo, tag) - cmd = exec.Command("/usr/bin/docker", "tag", name, name_) + cmd = exec.Command("/usr/bin/docker", "tag") + if vargs.ForceTag { + cmd.Args = append(cmd.Args, "--force=true") + } + cmd.Args = append(cmd.Args, name, name_) cmd.Dir = workspace.Path cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr