From eec8333242955eda3d154f4044e07c1a60324902 Mon Sep 17 00:00:00 2001 From: Tom Limoncelli Date: Mon, 16 Dec 2024 14:42:05 -0500 Subject: [PATCH] Cleanup code --- commands/ppreviewPush.go | 7 +++++-- providers/bind/bindProvider.go | 14 ++++++-------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/commands/ppreviewPush.go b/commands/ppreviewPush.go index b71dfe529f..e8a16dca9a 100644 --- a/commands/ppreviewPush.go +++ b/commands/ppreviewPush.go @@ -581,7 +581,7 @@ func generatePopulateCorrections(provider *models.DNSProviderInstance, zoneName } return []*models.Correction{{ - Msg: fmt.Sprintf("Create zone '%s' in the '%s' profile", aceZoneName, provider.Name), + Msg: fmt.Sprintf("Ensuring zone %q exists in %q", aceZoneName, provider.Name), F: func() error { return creator.EnsureZoneExists(aceZoneName) }, }} } @@ -604,7 +604,10 @@ func generateDelegationCorrections(zone *models.DomainConfig, providers []*model nameservers.AddNSRecords(zone) if len(zone.Nameservers) == 0 && zone.Metadata["no_ns"] != "true" { - return []*models.Correction{{Msg: fmt.Sprintf("No nameservers declared for domain %q; skipping registrar. Add {no_ns:'true'} to force", zone.Name)}}, 0 + return []*models.Correction{{Msg: fmt.Sprintf("Skipping registrar %q: No nameservers declared for domain %q. Add {no_ns:'true'} to force", + zone.RegistrarName, + zone.Name, + )}}, 0 } corrections, err := zone.RegistrarInstance.Driver.GetRegistrarCorrections(zone) diff --git a/providers/bind/bindProvider.go b/providers/bind/bindProvider.go index e7bf07ead7..68b83b4265 100644 --- a/providers/bind/bindProvider.go +++ b/providers/bind/bindProvider.go @@ -35,7 +35,7 @@ var features = providers.DocumentationNotes{ // See providers/capabilities.go for the entire list of capabilities. providers.CanAutoDNSSEC: providers.Can("Just writes out a comment indicating DNSSEC was requested"), providers.CanGetZones: providers.Can(), - providers.CanConcur: providers.Cannot(), + providers.CanConcur: providers.Can(), providers.CanUseCAA: providers.Can(), providers.CanUseDHCID: providers.Can(), providers.CanUseDNAME: providers.Can(), @@ -126,8 +126,6 @@ type bindProvider struct { nameservers []*models.Nameserver directory string filenameformat string - //zonefile string // Where the zone data is e texpected - //zoneFileFound bool // Did the zonefile exist? } // GetNameservers returns the nameservers for a domain. @@ -184,18 +182,14 @@ func (c *bindProvider) GetZoneRecords(domain string, meta map[string]string) (mo content, err := os.ReadFile(zonefile) if os.IsNotExist(err) { // If the file doesn't exist, that's not an error. Just informational. - //c.zoneFileFound = false fmt.Fprintf(os.Stderr, "File does not yet exist: %q (will create)\n", zonefile) return nil, nil } if err != nil { return nil, fmt.Errorf("can't open %s: %w", zonefile, err) } - //c.zoneFileFound = true - zonefileName := zonefile - - return ParseZoneContents(string(content), domain, zonefileName) + return ParseZoneContents(string(content), domain, zonefile) } // ParseZoneContents parses a string as a BIND zone and returns the records. @@ -217,6 +211,10 @@ func ParseZoneContents(content string, zoneName string, zonefileName string) (mo return foundRecords, nil } +func (n *bindProvider) EnsureZoneExists(_ string) error { + return nil +} + // GetZoneRecordsCorrections returns a list of corrections that will turn existing records into dc.Records. func (c *bindProvider) GetZoneRecordsCorrections(dc *models.DomainConfig, foundRecords models.Records) ([]*models.Correction, int, error) { var corrections []*models.Correction