Deprecate dns settings api and add dns data migration
This commit is contained in:
@@ -12,7 +12,10 @@ var apps = require('./apps.js'),
|
||||
async = require('async'),
|
||||
config = require('./config.js'),
|
||||
certificates = require('./certificates.js'),
|
||||
DatabaseError = require('./databaseerror.js'),
|
||||
debug = require('debug')('box:platform'),
|
||||
domains = require('./domains.js'),
|
||||
DomainError = domains.DomainError,
|
||||
fs = require('fs'),
|
||||
hat = require('hat'),
|
||||
infra = require('./infra_version.js'),
|
||||
@@ -22,6 +25,7 @@ var apps = require('./apps.js'),
|
||||
safe = require('safetydance'),
|
||||
semver = require('semver'),
|
||||
settings = require('./settings.js'),
|
||||
settingsdb = require('./settingsdb.js'),
|
||||
shell = require('./shell.js'),
|
||||
subdomains = require('./subdomains.js'),
|
||||
taskmanager = require('./taskmanager.js'),
|
||||
@@ -64,6 +68,7 @@ function start(callback) {
|
||||
debug('Updating infrastructure from %s to %s', existingInfra.version, infra.version);
|
||||
|
||||
async.series([
|
||||
migrateDNSSettings,
|
||||
stopContainers.bind(null, existingInfra),
|
||||
startAddons.bind(null, existingInfra),
|
||||
removeOldImages,
|
||||
@@ -377,3 +382,24 @@ function startApps(existingInfra, callback) {
|
||||
apps.configureInstalledApps(callback);
|
||||
}
|
||||
}
|
||||
|
||||
// This is only used when updating from single to multi domain support
|
||||
// REMOVE later!
|
||||
function migrateDNSSettings(callback) {
|
||||
assert.strictEqual(typeof callback, 'function');
|
||||
|
||||
settingsdb.get('dns_config', function (error, result) {
|
||||
if (error && error.reason !== DatabaseError.NOT_FOUND) return callback(error);
|
||||
|
||||
const dnsConfig = result ? safe.JSON.parse(result) : { provider: 'manual' };
|
||||
|
||||
domains.get(config.fqdn(), function (error, result) {
|
||||
if (error && error.reason !== DomainError.NOT_FOUND) return callback(error);
|
||||
|
||||
// if domain is already in the table, nothing to do
|
||||
if (result) return callback(null);
|
||||
|
||||
domains.add(config.fqdn(), config.zoneName(), dnsConfig, callback);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user