docker-sidecar
Advanced tools
Comparing version 1.1.0 to 1.2.0
@@ -8,3 +8,10 @@ #!/usr/bin/env node | ||
const rc = require('rc'); | ||
const os = require('os'); | ||
const join = require('path').join; | ||
let dockerAuth; | ||
try { | ||
dockerAuth = require(join(os.homedir(), '.docker', 'config.json')).auths; | ||
} catch (_) { | ||
} | ||
const cfg = rc('sidecar', { | ||
@@ -18,10 +25,3 @@ consul: 'http://127.0.0.1:8500', | ||
}, | ||
docker: { | ||
'index.docker.io': { | ||
email: undefined, | ||
auth: undefined, | ||
username: undefined, | ||
password: undefined | ||
} | ||
} | ||
docker: dockerAuth | ||
} | ||
@@ -95,7 +95,7 @@ }, require('minimist')(process.argv, { | ||
puller.watch.on('error', function (err) { | ||
puller.watch.on('error', (err) => { | ||
log.error({err: err}, 'watch error'); | ||
}); | ||
puller.watch.on('change', function (data, res) { | ||
puller.watch.on('change', (data, res) => { | ||
log.debug({data: data}, 'dir change'); | ||
@@ -105,11 +105,17 @@ puller.pull(); | ||
puller.docker.on('error', function (err) { | ||
puller.docker.on('error', (err) => { | ||
console.error(err.stack); | ||
log.error({err: err}, 'docker error'); | ||
}); | ||
puller.docker.on('finish', function (output) { | ||
log.info({finalStatus: output.slice(-1)}, 'docker finished'); | ||
puller.docker.on('pull', (pull) => { | ||
log.info({pull: pull}, 'docker pull'); | ||
}); | ||
puller.docker.on('engine_connect', (event) => { | ||
log.debug({event: event}, 'engine_connnect'); | ||
puller.pull(); | ||
}); | ||
log.info('initialized sidecar'); | ||
}).done(); |
17
index.js
@@ -8,5 +8,5 @@ 'use strict'; | ||
const assert = require('assert'); | ||
const method = Bluebird.method; | ||
const getEvents = require('./docker-events'); | ||
const sidecar = method(function (opts) { | ||
const sidecar = co.wrap(function *(opts) { | ||
opts = opts || {}; | ||
@@ -18,6 +18,13 @@ const consul = opts.consul; | ||
const dockerAuth = opts.dockerAuth; | ||
const dockerEvents = yield getEvents(docker); | ||
dockerEvents.on('data', (event) => { | ||
if (typeof event.status === 'string') { | ||
out.emit(event.status, event); | ||
} | ||
}); | ||
function onFinished (err, output) { | ||
// output is an array with output json parsed objects | ||
if (err) { | ||
out.emit(err); | ||
out.emit('error', err); | ||
} else { | ||
@@ -38,3 +45,3 @@ out.emit('finish', output); | ||
const images = keyval.filter(Boolean).map(k => k.Value).filter(Boolean); | ||
debug('images: %j', images); | ||
debug('images: %j, auths: %j', images, dockerAuth); | ||
for (let image of images) { | ||
@@ -41,0 +48,0 @@ const registries = Object.keys(dockerAuth).filter((registry) => image.indexOf(registry) === 0); |
{ | ||
"name": "docker-sidecar", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "Watch a consul kv dir for changes to retrieve a list of images and tags and pull them into docker when kv prefix changes.", | ||
@@ -24,4 +24,6 @@ "main": "index.js", | ||
"dockerode": "^2.2.9", | ||
"jsonstream2": "^1.1.1", | ||
"minimist": "^1.2.0", | ||
"rc": "^1.1.6", | ||
"split2": "^2.0.1", | ||
"xtend": "^4.0.1" | ||
@@ -28,0 +30,0 @@ }, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9638
10
169
10
1
+ Addedjsonstream2@^1.1.1
+ Addedsplit2@^2.0.1
+ Addedjsonparse@0.0.6(transitive)
+ Addedjsonstream2@1.1.2(transitive)
+ Addedsplit2@2.2.0(transitive)
+ Addedthrough2@0.6.52.0.5(transitive)
+ Addedtype-component@0.0.1(transitive)