🌳
pt0/deployF/hostnameF/listCfDnsRecordsAI.mts
5export const listcfdnsrecords = async () => {
6 const {cfApiKeySecretName, domainNames} = getKlusterCtx()
8 const headers = getCfHeaders({cfApiKeySecretName})
10 const zones = await cfFetch('/zones', headers)
12 for (const domainName of domainNames) {
13 const zone = zones.find((z: any) => z.name === domainName)
14 if (!zone) {
15 console.log(`⚠️ Zone not found: ${domainName}`)
16 continue
17 }
19 console.log(`\n=== ${domainName} (${zone.id}) ===`)
21 const records = await cfFetch(`/zones/${zone.id}/dns_records?per_page=100`, headers)
23 const wildcardRecords = records.filter((r: any) => r.name.startsWith('*'))
24 const txtRecords = records.filter((r: any) => r.type === 'TXT' && r.content.includes('heritage=external-dns'))
26 if (wildcardRecords.length > 0) {
27 console.log('\nWildcard records:')
28 wildcardRecords.forEach((r: any) => {
29 console.log(` ${r.type.padEnd(6)} ${r.name.padEnd(40)} → ${r.content || r.data?.target || 'N/A'}`)
30 })
31 }
33 if (txtRecords.length > 0) {
34 console.log('\nExternal-DNS TXT records:')
35 txtRecords.forEach((r: any) => {
36 const shortContent = r.content.slice(0, 80) + (r.content.length > 80 ? '...' : '')
37 console.log(` ${r.name.padEnd(40)} ${shortContent}`)
38 })
39 }
41 console.log(`\nTotal records: ${records.length}`)
42 }
45listcfdnsrecords.cliDescript = 'list DNS records in Cloudflare zones for this cluster'
46listcfdnsrecords.cliAdvanced = true