subdomains.add takes array values
This commit is contained in:
+1
-3
@@ -246,12 +246,10 @@ function downloadIcon(app, callback) {
|
||||
function registerSubdomain(app, callback) {
|
||||
// even though the bare domain is already registered in the appstore, we still
|
||||
// need to register it so that we have a dnsRecordId to wait for it to complete
|
||||
var record = { subdomain: app.location, type: 'A', value: sysinfo.getIp() };
|
||||
|
||||
async.retry({ times: 200, interval: 5000 }, function (retryCallback) {
|
||||
debugApp(app, 'Registering subdomain location [%s]', app.location);
|
||||
|
||||
subdomains.add(record, function (error, changeId) {
|
||||
subdomains.add(app.location, 'A', [ sysinfo.getIp() ], function (error, changeId) {
|
||||
if (error && (error.reason === SubdomainError.STILL_BUSY || error.reason === SubdomainError.EXTERNAL_ERROR)) return retryCallback(error); // try again
|
||||
|
||||
retryCallback(null, error || changeId);
|
||||
|
||||
+5
-6
@@ -3,7 +3,7 @@
|
||||
'use strict';
|
||||
|
||||
exports = module.exports = {
|
||||
addSubdomain: addSubdomain,
|
||||
add: add,
|
||||
delSubdomain: delSubdomain,
|
||||
updateSubdomain: updateSubdomain,
|
||||
getChangeStatus: getChangeStatus,
|
||||
@@ -17,20 +17,20 @@ var assert = require('assert'),
|
||||
superagent = require('superagent'),
|
||||
util = require('util');
|
||||
|
||||
function addSubdomain(zoneName, subdomain, type, value, callback) {
|
||||
function add(zoneName, subdomain, type, values, callback) {
|
||||
assert.strictEqual(typeof zoneName, 'string');
|
||||
assert.strictEqual(typeof subdomain, 'string');
|
||||
assert.strictEqual(typeof type, 'string');
|
||||
assert.strictEqual(typeof value, 'string');
|
||||
assert(util.isArray(values));
|
||||
assert.strictEqual(typeof callback, 'function');
|
||||
|
||||
var fqdn = subdomain !== '' && type === 'TXT' ? subdomain + '.' + config.fqdn() : config.appFqdn(subdomain);
|
||||
|
||||
debug('addSubdomain: zoneName: %s subdomain: %s type: %s value: %s fqdn: %s', zoneName, subdomain, type, value, fqdn);
|
||||
debug('add: %s for zone %s of type %s with values %j', subdomain, zoneName, type, values);
|
||||
|
||||
var data = {
|
||||
type: type,
|
||||
values: [ value ]
|
||||
values: values
|
||||
};
|
||||
|
||||
superagent
|
||||
@@ -46,7 +46,6 @@ function addSubdomain(zoneName, subdomain, type, value, callback) {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function getSubdomain(zoneName, subdomain, type, callback) {
|
||||
assert.strictEqual(typeof zoneName, 'string');
|
||||
assert.strictEqual(typeof subdomain, 'string');
|
||||
|
||||
+6
-7
@@ -3,7 +3,7 @@
|
||||
'use strict';
|
||||
|
||||
exports = module.exports = {
|
||||
addSubdomain: addSubdomain,
|
||||
add: add,
|
||||
delSubdomain: delSubdomain,
|
||||
updateSubdomain: updateSubdomain,
|
||||
getChangeStatus: getChangeStatus
|
||||
@@ -14,7 +14,8 @@ var assert = require('assert'),
|
||||
config = require('../config.js'),
|
||||
debug = require('debug')('box:dns/route53'),
|
||||
settings = require('../settings.js'),
|
||||
SubdomainError = require('../subdomainerror.js');
|
||||
SubdomainError = require('../subdomainerror.js'),
|
||||
util = require('util');
|
||||
|
||||
function getDnsCredentials(callback) {
|
||||
assert.strictEqual(typeof callback, 'function');
|
||||
@@ -60,16 +61,14 @@ function getZoneByName(zoneName, callback) {
|
||||
});
|
||||
}
|
||||
|
||||
function addSubdomain(zoneName, subdomain, type, value, callback) {
|
||||
function add(zoneName, subdomain, type, values, callback) {
|
||||
assert.strictEqual(typeof zoneName, 'string');
|
||||
assert.strictEqual(typeof subdomain, 'string');
|
||||
assert.strictEqual(typeof type, 'string');
|
||||
assert.strictEqual(typeof value, 'string');
|
||||
assert(util.isArray(values));
|
||||
assert.strictEqual(typeof callback, 'function');
|
||||
|
||||
debug('addSubdomain: ' + subdomain + ' for domain ' + zoneName + ' with value ' + value);
|
||||
|
||||
var values = [ value ];
|
||||
debug('add: %s for zone %s of type %s with values %j', subdomain, zoneName, type, values);
|
||||
|
||||
getZoneByName(zoneName, function (error, zone) {
|
||||
if (error) return callback(error);
|
||||
|
||||
+7
-9
@@ -7,7 +7,8 @@ var assert = require('assert'),
|
||||
config = require('./config.js'),
|
||||
debug = require('debug')('box:subdomains'),
|
||||
route53 = require('./dns/route53.js'),
|
||||
SubdomainError = require('./subdomainerror.js');
|
||||
SubdomainError = require('./subdomainerror.js'),
|
||||
util = require('util');
|
||||
|
||||
module.exports = exports = {
|
||||
add: add,
|
||||
@@ -22,16 +23,13 @@ function api() {
|
||||
return config.isCustomDomain() || config.TEST ? route53 : caas;
|
||||
}
|
||||
|
||||
function add(record, callback) {
|
||||
assert.strictEqual(typeof record, 'object');
|
||||
assert.strictEqual(typeof record.subdomain, 'string');
|
||||
assert.strictEqual(typeof record.type, 'string');
|
||||
assert.strictEqual(typeof record.value, 'string');
|
||||
function add(subdomain, type, values, callback) {
|
||||
assert.strictEqual(typeof subdomain, 'string');
|
||||
assert.strictEqual(typeof type, 'string');
|
||||
assert(util.isArray(values));
|
||||
assert.strictEqual(typeof callback, 'function');
|
||||
|
||||
debug('add: ', record);
|
||||
|
||||
api().addSubdomain(config.zoneName(), record.subdomain, record.type, record.value, function (error, changeId) {
|
||||
api().add(config.zoneName(), subdomain, type, values, function (error, changeId) {
|
||||
if (error) return callback(error);
|
||||
callback(null, changeId);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user