From 44a50c06ac71fdaca2fcdff937d8548e360c28e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Tremblay?= Date: Wed, 15 Mar 2017 12:15:19 -0700 Subject: [PATCH] joyent/node-triton#190 Exception when using current docker client MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marc-André Tremblay --- lib/do_profile/profilecommon.js | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/lib/do_profile/profilecommon.js b/lib/do_profile/profilecommon.js index aeba41d..ea44215 100644 --- a/lib/do_profile/profilecommon.js +++ b/lib/do_profile/profilecommon.js @@ -459,10 +459,32 @@ function profileDockerSetup(opts, cb) { if (!arg.dockerVersion) { setup.env.DOCKER_CLIENT_TIMEOUT = '300'; setup.env.COMPOSE_HTTP_TIMEOUT = '300'; - } else if (semver.gte(arg.dockerVersion, '1.9.0')) { - setup.env.COMPOSE_HTTP_TIMEOUT = '300'; } else { - setup.env.DOCKER_CLIENT_TIMEOUT = '300'; + + /* + * We now need to parse version numbers differently since the + * introduction of Docker CE and EE. semver won't like them. + */ + var versionNumberExp = /(?:\d+\.){2}\d+/; + var versionNumber = versionNumberExp.exec(arg.dockerVersion)[0]; + + /* + * semver also doesn't seem to like versions like `17.03.0'. + * The prefixing 0 in the minor number of the exemple seems + * to hurt it. Let's parse them back to numbers with no + * prefixing `0's. + */ + + versionNumber = versionNumber + .split('.') + .map(function (strnum) { return parseInt(strnum, 10); }) + .join('.'); + + if (semver.gte(versionNumber, '1.9.0')) { + setup.env.COMPOSE_HTTP_TIMEOUT = '300'; + } else { + setup.env.DOCKER_CLIENT_TIMEOUT = '300'; + } } fs.writeFile(setupJson,