Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion packages/dns/googledns/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,20 @@ export default defineDns<Config>({
const project = config.projectId ?? _secret('GOOGLE_PROJECT_ID');
if (!project) throw new Error('GOOGLE_PROJECT_ID not set');
const [type, name] = recordId.split('/');
if (!type || !name) {
throw new Error('Google Cloud DNS deleteRecord: invalid record id');
}
// Need to fetch the rrset to get current rrdatas for the deletion entry.
const existing = (await this.listRecords(zoneId, config)).filter(
r => r.type === type && (r.name === name || r.name === name.replace(/\.$/, '')),
);
if (existing.length === 0) return;
const fqdn = name.endsWith('.') ? name : `${name}.`;
const ttl = existing[0].ttl;
const first = existing[0];
if (!first) {
throw new Error('Google Cloud DNS deleteRecord: matching record unavailable');
}
const ttl = first.ttl;
const res = await fetch(`${API}/projects/${project}/managedZones/${zoneId}/changes`, {
method: 'POST',
headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json' },
Expand Down