virgo-update-service
Advanced tools
Comparing version
{ | ||
"name": "virgo-update-service", | ||
"version": "0.0.23", | ||
"version": "0.0.24", | ||
"description": "Updater Service for Virgo Services", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -29,4 +29,4 @@ var _ = require('underscore'); | ||
} | ||
if (!resp) { | ||
callback(null, []); | ||
if (!resp || !resp.node.nodes) { | ||
callback(new Error('channels do not exist')); | ||
return; | ||
@@ -33,0 +33,0 @@ } |
@@ -174,6 +174,6 @@ var async = require('async'); | ||
callback(err); | ||
} else { | ||
self._channels = results; | ||
callback(null, self._channels); | ||
return; | ||
} | ||
self._channels = results; | ||
callback(null, self._channels); | ||
}); | ||
@@ -284,3 +284,69 @@ }; | ||
Deploy.prototype._createChannels = function(callback) { | ||
var self = this, | ||
etcdClient = new etcd.Client(self.options.etcd_host, self.options.etcd_port); | ||
function iter(channel, callback) { | ||
var path = '/deploys/' + channel, | ||
create = false; | ||
async.series([ | ||
function(callback) { | ||
etcdClient.get(path, function(err) { | ||
if (err) { | ||
create = true; | ||
callback(); | ||
} else { | ||
callback(); | ||
} | ||
}); | ||
}, | ||
function(callback) { | ||
if (create) { | ||
log.info('Creating channel: ' + channel); | ||
etcdClient.set(path, JSON.stringify({version: self.options.default_channel_version}), callback); | ||
} else { | ||
callback(); | ||
} | ||
} | ||
], callback); | ||
} | ||
async.series([ | ||
function(callback) { | ||
etcdClient.mkdir('/deploys', function(err) { | ||
if (err) { | ||
log.info('mkdir failed creating /deploys', {err: err}); | ||
} | ||
callback(); | ||
}); | ||
}, | ||
function(callback) { | ||
async.forEach(self.options.default_channels, iter, callback); | ||
} | ||
], callback); | ||
}; | ||
Deploy.prototype.createDefaultChannels = function(callback) { | ||
var etcdClient = new etcd.Client(this.options.etcd_host, this.options.etcd_port), | ||
lockKey = 'virgo_creation_lock', | ||
global = new Global(), | ||
self = this; | ||
function perform(lock, callback) { | ||
async.series([ | ||
function(callback) { | ||
global.getChannels(function(err) { | ||
if (err) { | ||
self._createChannels(callback); | ||
} else { | ||
callback(); | ||
} | ||
}); | ||
} | ||
], callback); | ||
} | ||
etcdClient.lock(lockKey, 30, perform, callback); | ||
}; | ||
exports.Deploy = Deploy; |
@@ -11,2 +11,3 @@ var api = require('./api'); | ||
var registry = require('etcd-registry'); | ||
var sprintf = require('sprintf').sprintf; | ||
var url = require('url'); | ||
@@ -74,2 +75,12 @@ var _ = require('underscore'); | ||
} | ||
options.default_channels = process.env.VIRGO_UPDATE_SERVICE_DEFAULT_CHANNELS; | ||
if (!options.default_channels) { | ||
die('VIRGO_UPDATE_SERVICE_DEFAULT_CHANNELS is missing'); | ||
} else { | ||
options.default_channels = options.default_channels.split(','); | ||
} | ||
options.default_channel_version = process.env.VIRGO_UPDATE_SERVICE_DEFAULT_CHANNEL_VERSION; | ||
if (!options.default_channel_version) { | ||
die('VIRGO_UPDATE_SERVICE_DEFAULT_CHANNEL_VERSION is missing'); | ||
} | ||
@@ -114,2 +125,5 @@ /* optional options */ | ||
log.infof('Using etcd ${host}:${port}', {host: options.etcd_host, port: options.etcd_port}); | ||
log.infof('Listening on ${host}:${port}', {host: options.bind_host, port: options.bind_port}); | ||
async.auto({ | ||
@@ -129,8 +143,10 @@ makedirs: function(callback) { | ||
}], | ||
deploy: ['register', function(callback) { | ||
log.infof('Using etcd hosts: ${hosts}', {hosts: options.etcd_hosts}); | ||
create: ['register', function(callback) { | ||
log.infof('Checking for default channels', {channels: options.default_channels}); | ||
de.createDefaultChannels(callback); | ||
}], | ||
deploy: ['create', function(callback) { | ||
de.run(callback); | ||
}], | ||
listen: ['deploy', function(callback) { | ||
log.infof('Listening on ${host}:${port}', {host: options.bind_host, port: options.bind_port}); | ||
server.listen(options.bind_port, options.bind_host, callback); | ||
@@ -137,0 +153,0 @@ }] |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
5503190
3.12%406
0.5%58049
0.13%34
6.25%