godaddy: do not remove all the records of type
This commit is contained in:
@@ -126,6 +126,13 @@ async function del(domainObject, location, type, values) {
|
||||
|
||||
debug(`del: ${name} in zone ${zoneName} of type ${type} with values ${JSON.stringify(values)}`);
|
||||
|
||||
const result = await get(domainObject, location, type);
|
||||
if (result.length === 0) return;
|
||||
|
||||
const tmp = result.filter(r => !values.includes(r));
|
||||
|
||||
if (tmp.length) return await upsert(domainObject, location, type, tmp); // only remove 'values'
|
||||
|
||||
const [error, response] = await safe(superagent.del(`${GODADDY_API}/${zoneName}/records/${type}/${name}`)
|
||||
.set('Authorization', `sso-key ${domainConfig.apiKey}:${domainConfig.apiSecret}`)
|
||||
.timeout(30 * 1000)
|
||||
|
||||
@@ -338,18 +338,13 @@ describe('dns provider', function () {
|
||||
data: '1.2.3.4'
|
||||
}];
|
||||
|
||||
const DOMAIN_RECORD_1 = [{ // replaced
|
||||
ttl: 600,
|
||||
data: '0.0.0.0'
|
||||
}];
|
||||
|
||||
const req1 = nock(GODADDY_API)
|
||||
.get('/' + domainCopy.zoneName + '/records/A/test')
|
||||
.reply(200, DOMAIN_RECORD_0);
|
||||
|
||||
const req2 = nock(GODADDY_API)
|
||||
.put('/' + domainCopy.zoneName + '/records/A/test', DOMAIN_RECORD_1)
|
||||
.reply(200, {});
|
||||
.delete('/' + domainCopy.zoneName + '/records/A/test')
|
||||
.reply(204, {});
|
||||
|
||||
await dns.removeDnsRecords('test', domainCopy.domain, 'A', ['1.2.3.4']);
|
||||
expect(req1.isDone()).to.be.ok();
|
||||
|
||||
Reference in New Issue
Block a user