Skip to content

Commit

Permalink
v1.0.6 release: Fixes Docker version number issues
Browse files Browse the repository at this point in the history
This changes the logic involved in checking for a minimum Docker version. Previously, we had a maximum version as well; with the pending release of v17.3 this needed to be updated to be more robust.

Tests for the change, including the upcoming version numbers have been added to `test/util_test.nim`, and pass.

Version has been bumped to v1.0.6
  • Loading branch information
girvo committed Mar 3, 2017
1 parent d9211f7 commit 0622ff2
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 8 deletions.
2 changes: 1 addition & 1 deletion dup.nimble
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[Package]
name = "dup"
version = "1.0.4"
version = "1.0.6"
author = "Josh Girvin <josh@jgirvin.com>, Nathan Craike <me@ncraike.com>"
description = "CLI wrapper for local Docker web development"
license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion src/container.nim
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ proc checkDockerfile*() {.raises: [].} =
if not existsFile(getCurrentDir() / "Dockerfile"):
writeError("Missing \"Dockerfile\" in current directory")
quit(254)
except OSError:
except:
writeError(getCurrentExceptionMsg(), true)
quit(1)

Expand Down
10 changes: 4 additions & 6 deletions src/dup.nim
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ from database import newDBConfig
from container import checkDockerfile, checkAndParseDupFile

## Define our version constant for re-use
const version = "dup 1.0.4"
const version = "dup 1.0.6"

## Define our docopt parsing schema
let doc = """
Expand Down Expand Up @@ -47,11 +47,9 @@ var
dbConf = newDBConfig(None) ## Default the database config to "None"
conf: ProjectConfig ## Configuration ref object

## Check Docker version, bail-out if it's not 1.12.x
let
dv = docker.getVersion()
isWrong = if dv.major == 1 and dv.minor == 12: false else: true
if isWrong:
## Check Docker version, bail-out if it's less than v1.12
let dv = docker.getVersion()
if isVersionTooOld(dv):
writeError("Please install Docker >= v1.12.0", true)
quit(5)

Expand Down
8 changes: 8 additions & 0 deletions src/util.nim
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,11 @@ proc writeStatus*(name: string, status: bool) =
stdout.write("not running")
stdout.resetAttributes()
stdout.write("\n")

proc isVersionTooOld*(dv: VersionNumber): bool =
result = false
if dv.major < 1:
result = true
elif dv.major == 1:
if dv.minor < 12:
result = true
1 change: 1 addition & 0 deletions test/runner.nim
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@

import ./docker_test
import ./config_test
import ./util_test
33 changes: 33 additions & 0 deletions test/util_test.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
## util.nim tests

import unittest
import options
import typetraits
import ../src/private/types

# Unit under test
import ../src/util

suite "util.isVersionTooOld":
setup: discard
teardown: discard

test "fails with incorrect major":
let version = newVersionNumber(0, 12, 0)
let result = isVersionTooOld(version)
check(result == true)

test "fails with correct major, incorrect minor":
let version = newVersionNumber(1, 11, 0)
let result = isVersionTooOld(version)
check(result == true)

test "passes with correct major/minor for version v1":
let version = newVersionNumber(1, 13, 0)
let result = isVersionTooOld(version)
check(result == false)

test "passes with correct major/minor for new release numbers":
let version = newVersionNumber(17, 3, 0)
let result = isVersionTooOld(version)
check(result == false)

0 comments on commit 0622ff2

Please # to comment.