small typos
This commit is contained in:
@@ -51,10 +51,10 @@ func init() {
|
||||
// CloudflareDNSRes is a resource for managing DNS records in Cloudflare zones.
|
||||
// This resource uses the Cloudflare API to create, update, and delete DNS
|
||||
// records in a specified zone. It supports various record types including A,
|
||||
// AAAA, CNAME, MX, TXT, NS, and PTR records. The resource requires polling
|
||||
// to detect changes, as the Cloudflare API does not provide an event stream.
|
||||
// The Purge functionality allows enforcing that only managed DNS records exist
|
||||
// in the zone, removing any unmanaged records.
|
||||
// AAAA, CNAME, MX, TXT, NS, and PTR records. The resource requires polling to
|
||||
// detect changes, as the Cloudflare API does not provide an event stream. The
|
||||
// Purge functionality allows enforcing that only managed DNS records exist in
|
||||
// the zone, removing any unmanaged records.
|
||||
type CloudflareDNSRes struct {
|
||||
traits.Base
|
||||
traits.GraphQueryable
|
||||
@@ -130,7 +130,7 @@ func (obj *CloudflareDNSRes) Validate() error {
|
||||
}
|
||||
|
||||
if obj.APIToken == "" {
|
||||
return fmt.Errorf("API token is required")
|
||||
return fmt.Errorf("api token is required")
|
||||
}
|
||||
|
||||
if obj.Type == "" {
|
||||
@@ -138,7 +138,7 @@ func (obj *CloudflareDNSRes) Validate() error {
|
||||
}
|
||||
|
||||
if (obj.TTL < 60 || obj.TTL > 86400) && obj.TTL != 1 { // API requirement
|
||||
return fmt.Errorf("TTL must be between 60s and 86400s, or set to 1")
|
||||
return fmt.Errorf("ttl must be between 60s and 86400s, or set to 1")
|
||||
}
|
||||
|
||||
if obj.Zone == "" {
|
||||
@@ -578,7 +578,7 @@ func (obj *CloudflareDNSRes) needsUpdate(record dns.RecordResponse) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// TODO add more checks?
|
||||
//TODO: add more checks?
|
||||
|
||||
return false
|
||||
|
||||
@@ -679,16 +679,18 @@ func (obj *CloudflareDNSRes) GraphQueryAllowed(opts ...engine.GraphQueryableOpti
|
||||
return nil
|
||||
}
|
||||
|
||||
// matchesRecordName checks if a record name from the API matches our desired record name.
|
||||
// Handles both FQDN (www.example.com) and short form (www) comparisons.
|
||||
// matchesRecordName checks if a record name from the API matches our desired
|
||||
// record name. Handles both FQDN (www.example.com) and short form (www)
|
||||
// comparisons.
|
||||
func (obj *CloudflareDNSRes) matchesRecordName(apiRecordName string) bool {
|
||||
desired := obj.normalizeRecordName(obj.RecordName)
|
||||
actual := obj.normalizeRecordName(apiRecordName)
|
||||
return desired == actual
|
||||
}
|
||||
|
||||
// normalizeRecordName converts a record name to a consistent format for comparison.
|
||||
// Converts to FQDN format (e.g., "www" -> "www.example.com", "@" -> "example.com")
|
||||
// normalizeRecordName converts a record name to a consistent format for
|
||||
// comparison. Converts to FQDN format (e.g., "www" -> "www.example.com", "@" ->
|
||||
// "example.com")
|
||||
func (obj *CloudflareDNSRes) normalizeRecordName(name string) string {
|
||||
if name == "@" || name == obj.Zone {
|
||||
return obj.Zone
|
||||
|
||||
Reference in New Issue
Block a user