merge settingsdb into settings code
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
|
||||
exports = module.exports = {
|
||||
testRegistryConfig,
|
||||
setRegistryConfig,
|
||||
injectPrivateFields,
|
||||
removePrivateFields,
|
||||
|
||||
@@ -37,7 +36,6 @@ const apps = require('./apps.js'),
|
||||
async = require('async'),
|
||||
assert = require('assert'),
|
||||
BoxError = require('./boxerror.js'),
|
||||
child_process = require('child_process'),
|
||||
constants = require('./constants.js'),
|
||||
debug = require('debug')('box:docker'),
|
||||
Docker = require('dockerode'),
|
||||
@@ -48,6 +46,7 @@ const apps = require('./apps.js'),
|
||||
shell = require('./shell.js'),
|
||||
safe = require('safetydance'),
|
||||
system = require('./system.js'),
|
||||
util = require('util'),
|
||||
volumes = require('./volumes.js'),
|
||||
_ = require('underscore');
|
||||
|
||||
@@ -82,22 +81,6 @@ function removePrivateFields(registryConfig) {
|
||||
return registryConfig;
|
||||
}
|
||||
|
||||
function setRegistryConfig(config, callback) {
|
||||
assert.strictEqual(typeof config, 'object');
|
||||
assert.strictEqual(typeof callback, 'function');
|
||||
|
||||
const isLogin = !!config.password;
|
||||
|
||||
// currently, auth info is not stashed in the db but maybe it should for restore to work?
|
||||
const cmd = isLogin ? `docker login ${config.serverAddress} --username ${config.username} --password ${config.password}` : `docker logout ${config.serverAddress}`;
|
||||
|
||||
child_process.exec(cmd, { }, function (error /*, stdout, stderr */) {
|
||||
if (error) return callback(new BoxError(BoxError.ACCESS_DENIED, error.message));
|
||||
|
||||
callback();
|
||||
});
|
||||
}
|
||||
|
||||
function ping(callback) {
|
||||
assert.strictEqual(typeof callback, 'function');
|
||||
|
||||
@@ -118,7 +101,7 @@ function getRegistryConfig(image, callback) {
|
||||
const parts = image.split('/');
|
||||
if (parts.length === 1 || (parts[0].match(/[.:]/) === null)) return callback(null, null); // public docker registry
|
||||
|
||||
settings.getRegistryConfig(function (error, registryConfig) {
|
||||
util.callbackify(settings.getRegistryConfig)(function (error, registryConfig) {
|
||||
if (error) return callback(error);
|
||||
|
||||
// https://github.com/apocas/dockerode#pull-from-private-repos
|
||||
|
||||
Reference in New Issue
Block a user