docker-tools
Advanced tools
Comparing version 0.0.1 to 0.0.2
44
index.js
@@ -1,40 +0,8 @@ | ||
var when = require('when'); | ||
var findNecessaryContainers = require('./lib/findNecessaryContainers'); | ||
var createContainer = require('./lib/createContainer'); | ||
function resolveConfigurationAndStartContainers (config, callback) { | ||
if (!config.docker || !config.docker.enabled) { | ||
return callback(null, config); | ||
module.exports = { | ||
get resolveConfigurationAndStartContainers () { | ||
return require('./lib/resolveConfigurationAndStartContainers'); | ||
}, | ||
get DockerContainer () { | ||
return require('./lib/Container') | ||
} | ||
var containers = findNecessaryContainers(config); | ||
if (containers.length === 0) { | ||
return callback(null, config); | ||
} | ||
when.map(containers, function (containerSpec) { | ||
return createContainer(config.docker.options, containerSpec); | ||
}).then(function (containers) { | ||
containers.forEach(function (container) { | ||
var configKey = container.containerSpec.key; | ||
var newValue = container.containerSpec.value; | ||
for (var prop in newValue) { | ||
var value = newValue[prop]; | ||
if (newValue.hasOwnProperty(prop) && typeof value === 'string') { | ||
value = value.replace(/\{docker_port\}/g, container.info.port); | ||
value = value.replace(/\{docker_host\}/g, container.info.ip); | ||
newValue[prop] = value.replace(/\{docker_env:([a-zA-Z_]+)\}/g, function (match, key) { | ||
return container.containerSpec.docker.env[key]; | ||
}); | ||
} | ||
} | ||
config[configKey] = newValue; | ||
}); | ||
callback(null, config); | ||
}, callback); | ||
}; | ||
module.exports = resolveConfigurationAndStartContainers; |
{ | ||
"name": "docker-tools", | ||
"description": "Tools for working with Docker containers in Node.js.", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"main": "index.js", | ||
@@ -6,0 +6,0 @@ "scripts": { |
20222
16
496