small typos

This commit is contained in:
Lourenço Vales
2025-10-05 23:13:58 +02:00
parent 0784060d05
commit ad86804f56

View File

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