diff --git a/src/config.coffee b/src/config.coffee index 617711bb..2447a7e7 100644 --- a/src/config.coffee +++ b/src/config.coffee @@ -4,5 +4,14 @@ module.exports = config = pubnub: subscribe_key: process.env.PUBNUB_SUBSCRIBE_KEY publish_key: process.env.PUBNUB_PUBLISH_KEY + expectedEnvVars: [ + 'API_ENDPOINT' + 'REGISTRY_ENDPOINT' + 'PUBNUB_SUBSCRIBE_KEY' + 'PUBNUB_PUBLISH_KEY' + ] + +# A check that all variables are set and notify the user if not +for envVar in config.expectedEnvVars when !process.env[envVar]? + console.error('Cannot find env var:', envVar) -# TODO add a check that all variables are set and notify the user if not diff --git a/src/supervisor-update.coffee b/src/supervisor-update.coffee index b85c0343..4f6abb9c 100644 --- a/src/supervisor-update.coffee +++ b/src/supervisor-update.coffee @@ -12,7 +12,7 @@ Promise.promisifyAll(docker.getImage().__proto__) Promise.promisifyAll(docker.getContainer().__proto__) localImage = 'resin/rpi-supervisor' -remoteImage = config.REGISTRY_ENDPOINT + '/' + localImage +remoteImage = config.registryEndpoint + '/' + localImage supervisorUpdating = Promise.resolve() exports.update = -> @@ -44,10 +44,9 @@ exports.update = -> '/boot/config.json': '/mnt/mmcblk0p1/config.json' '/data': '/var/lib/docker/data' '/run/docker.sock': '/var/run/docker.sock' - Env: [ - 'API_ENDPOINT=' + config.API_ENDPOINT - 'REGISTRY_ENDPOINT=' + config.REGISTRY_ENDPOINT - ] + Env: + for envVar in config.expectedEnvVars + envVar + '=' + process.env[envVar] ) .then (container) -> console.log('Starting updated supervisor container:', localImage)