Skip to content

Commit

Permalink
Cleanup code
Browse files Browse the repository at this point in the history
  • Loading branch information
tlimoncelli committed Dec 16, 2024
1 parent 0548d5a commit eec8333
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
7 changes: 5 additions & 2 deletions commands/ppreviewPush.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) },
}}
}
Expand All @@ -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)
Expand Down
14 changes: 6 additions & 8 deletions providers/bind/bindProvider.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand All @@ -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
Expand Down

0 comments on commit eec8333

Please sign in to comment.