Add option to replace existing matched image tags

This commit is contained in:
Denis Parchenko 2015-11-25 17:55:12 +02:00
parent 0b2faea192
commit 24082f1d5c
2 changed files with 7 additions and 1 deletions

View File

@ -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

View File

@ -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