Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should have no updatable containers if one exists, but was pulled in the last 90 minutes', done => {
clock = sinon.useFakeTimers({
now: 1546329600000, // January 1, 2019 Midnight PST
shouldAdvanceTime: false,
});
dockerodeListAllContainers = sinon.stub(require('dockerode').prototype, 'listContainers')
.yields(null, dockerodeMocks.listAllContainers());
dockerodeListImages = sinon.stub(require('dockerode').prototype, 'listImages')
.yields(null, dockerodeMocks.listImagesWithUpdate());
requester
.get('/v1/telemetry/version')
.set('authorization', `JWT ${token}`)
.end((err, res) => {
if (err) {
done(err);
}
res.should.have.status(200);
res.should.be.json;
res.body.should.have.property('lnd');
res.body['lnd'].updatable.should.equal(false);
res.body.should.have.property('bitcoind');
res.body['bitcoind'].updatable.should.equal(false);
before(() => {
// Saving settings performs a `docker-compose up`
dockerodeListAllContainers = sinon.stub(require('dockerode').prototype, 'listContainers')
.yields(null, dockerodeMocks.listAllContainers());
dockerodeListImages = sinon.stub(require('dockerode').prototype, 'listImages')
.yields(null, dockerodeMocks.listImages());
const dockerCompose = `${__dirname}/../../../logic/docker-compose.js`;
dockerComposeUpStub = sinon.stub(require(dockerCompose), 'dockerComposeUpSingleService');
dockerComposeStopStub = sinon.stub(require(dockerCompose), 'dockerComposeStop');
dockerComposeRemoveStub = sinon.stub(require(dockerCompose), 'dockerComposeRemove');
const lnapi = `${__dirname}/../../../services/lnapi.js`;
unlockLndStub = sinon.stub(require(lnapi), 'unlockLnd');
});
// replace promises with bluebird
import Bluebird from 'bluebird';
import Docker from 'dockerode';
// promisify
Bluebird.promisifyAll(Docker.prototype);
// create new docker instance
const docker = new Docker(); // defaults to above if env variables are not used
// promisify network
const network = docker.getNetwork('promisify-net');
Bluebird.promisifyAll(network.constructor.prototype);
// promisify container
const container = docker.getContainer('promisify-container');
Bluebird.promisifyAll(container.constructor.prototype);
// promisify image
const image = docker.getImage('promisify-image');
Bluebird.promisifyAll(image.constructor.prototype);
export default docker;
var Docker = require('dockerode');
var q = require('q');
var _ = require('underscore');
Docker.prototype.imageExists = function(img) {
var self = this;
return q.Promise(function(resolve, fail, notify) {
self.listImages(function(err, images) {
var image_res;
var res = images.some(function(image) {
var img_name = image.RepoTags[0];
image_res = image;
return (img_name.indexOf(img) > -1)
});
if (res) {
resolve(image_res);
} else {
fail(img);
}
});
}
var Image = qify.factory(function(modem, name) {
return new oImage(modem, name);
}, list_methods(oImage));
var Container = qify.factory(function(modem, id) {
return new oContainer(modem, id);
}, list_methods(oContainer));
var AzkDocker = function(opts) {
this.modem = new Modem(opts);
}
AzkDocker.prototype = _.clone(oDocker.prototype);
AzkDocker.prototype.getContainer = function(id) {
return new Container(this.modem, id);
}
AzkDocker.prototype.getImage = function(name) {
return new Image(this.modem, name);
}
function new_resize(container) {
return function() {
var dimensions = {
h: process.stdout.rows,
w: process.stderr.columns
}
var res = images.some(function(image) {
var img_name = image.RepoTags[0];
image_res = image;
return (img_name.indexOf(img) > -1)
});
if (res) {
resolve(image_res);
} else {
fail(img);
}
});
});
}
Docker.prototype.containerExistsByName = function(cont) {
var self = this;
return q.Promise(function(resolve, fail, notify) {
self.listContainers({
all: 1
}, function(err, containers) {
var container_res;
var res = containers.some(function(container) {
container_res = container;
return container.Names.some(function(name) {
return (name == '/' + cont)
});
});
if (res) {
resolve(container_res);
'use strict'
const app = require('app')
const Config = require('./config')
const Promise = require('bluebird')
const child_process = Promise.promisifyAll(require('child_process'))
const parseColumns = require('parse-columns')
const fs = require('fs')
const Docker = require('dockerode')
const nullFn = function () {}
Promise.promisifyAll(Docker.prototype)
const dockerMachineCmd = function () {
return Config.get('machine_cmd') || '/usr/local/bin/docker-machine'
}
const dockerMachinePaths = function () {
return ['/usr/local/bin', '/usr/local/sbin', '/opt/bin', '/opt/sbin',
'/opt/local/bin', '/opt/local/sbin', '/usr/bin', '/bin', '/usr/sbin', '/sbin']
}
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'
process.env.PATH = dockerMachinePaths().join(':')
exports.machineAction = function (args) {
args.unshift(dockerMachineCmd())
return child_process.execAsync(args.join(' '), { cwd: app.getAppPath() })