reuse the func DockerDriver.Version()
This commit is contained in:
parent
5eae809b0c
commit
66615e3f56
|
@ -284,27 +284,25 @@ func (d *DockerDriver) TagImage(id string, repo string, force bool) error {
|
|||
// for more detail, please refer to the following links:
|
||||
// - https://docs.docker.com/engine/deprecated/#/f-flag-on-docker-tag
|
||||
// - https://github.com/docker/docker/pull/23090
|
||||
output, err := exec.Command("docker", "--version").Output()
|
||||
version_running, err := d.Version()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
match := regexp.MustCompile(version.VersionRegexpRaw).FindSubmatch(output)
|
||||
if match == nil {
|
||||
return fmt.Errorf("Unknown Docker version: %s", output)
|
||||
version_deprecated, err := version.NewVersion(string("1.12.0"))
|
||||
if err != nil {
|
||||
// should never reach this line
|
||||
return err
|
||||
}
|
||||
|
||||
version_running, _ := version.NewVersion(string(match[0]))
|
||||
version_deprecated, _ := version.NewVersion("1.12.0")
|
||||
|
||||
if version_running.LessThan(version_deprecated) {
|
||||
if force {
|
||||
if force {
|
||||
if version_running.LessThan(version_deprecated) {
|
||||
args = append(args, "-f")
|
||||
} else {
|
||||
// do nothing if Docker version >= 1.12.0
|
||||
log.Printf("[WARN] option: \"force\" will be ignored here")
|
||||
log.Printf("since it was removed after Docker 1.12.0 released")
|
||||
}
|
||||
} else {
|
||||
// do nothing if Docker version >= 1.12.0
|
||||
log.Printf("[WARN] option: \"force\" will be ignored here")
|
||||
log.Printf("since it was removed after Docker 1.12.0 released")
|
||||
}
|
||||
args = append(args, id, repo)
|
||||
|
||||
|
|
Loading…
Reference in New Issue