From 0b97ed3b9ff6930f7f538f8964892c72d0c81f32 Mon Sep 17 00:00:00 2001 From: Nick Hale <4175918+njhale@users.noreply.github.com> Date: Wed, 24 May 2023 12:31:00 -0400 Subject: [PATCH] Elide "local" records from purge set Prevent records for "*.local.$BASE" domains from being deleted. Signed-off-by: Nick Hale <4175918+njhale@users.noreply.github.com> --- pkg/backend/purger.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/backend/purger.go b/pkg/backend/purger.go index 052903d..beb153f 100644 --- a/pkg/backend/purger.go +++ b/pkg/backend/purger.go @@ -71,6 +71,14 @@ func (b *backend) purge() { return } + // Elide records for "local" FQDNs, these won't exist in the database but shouldn't be deleted. + localSuffix := ".local." + b.baseDomain + for pair := range recordsToDelete { + if strings.HasSuffix(pair.FQDN, localSuffix) { + delete(recordsToDelete, pair) + } + } + if len(recordsToDelete) == 0 { logrus.Infof("Records purged from Route53: 0") return