Compare commits
2 Commits
ce4d2bfe50
...
3b3b7aebb1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3b3b7aebb1 | ||
|
|
2182e2a4ea |
@@ -74,14 +74,10 @@ type CloudflareDNSRes struct {
|
||||
// Type (e.g., IP address for A records, hostname for CNAME records).
|
||||
Content string `lang:"content"`
|
||||
|
||||
// Data is a value that's specific for SRV records, containing the priority,
|
||||
// weight, port, and SRV targets.
|
||||
Data *dns.SRVRecordData `lang:"srv_data"`
|
||||
|
||||
// Priority is the priority value for records that support it (e.g., MX
|
||||
// records). This is a pointer to distinguish between an unset value and
|
||||
// a zero value.
|
||||
Priority *int64 `lang:"priority"`
|
||||
Priority *float64 `lang:"priority"`
|
||||
|
||||
// Proxied specifies whether the record should be proxied through
|
||||
// Cloudflare's CDN. This is a pointer to distinguish between an unset
|
||||
@@ -179,7 +175,6 @@ func (obj *CloudflareDNSRes) Init(init *engine.Init) error {
|
||||
option.WithAPIToken(obj.APIToken),
|
||||
)
|
||||
|
||||
//TODO: does it make more sense to check it here or in CheckApply()?
|
||||
zoneListParams := zones.ZoneListParams{
|
||||
Name: cloudflare.F(obj.Zone),
|
||||
}
|
||||
@@ -365,14 +360,10 @@ func (obj *CloudflareDNSRes) Cmp(r engine.Res) error {
|
||||
return fmt.Errorf("the priority param differs")
|
||||
}
|
||||
|
||||
if obj.Priority != nil && *obj.Priority != *obj.Priority {
|
||||
if obj.Priority != nil && *obj.Priority != *res.Priority {
|
||||
return fmt.Errorf("the priority param differs")
|
||||
}
|
||||
|
||||
if obj.Data != res.Data {
|
||||
return fmt.Errorf("the data param differs")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -440,7 +431,7 @@ func (obj *CloudflareDNSRes) buildRecordParam() (any, error) {
|
||||
param.Proxied = cloudflare.F(*obj.Proxied)
|
||||
}
|
||||
if obj.Priority != nil { // required for MX record
|
||||
param.Priority = cloudflare.F(float64(*obj.Priority))
|
||||
param.Priority = cloudflare.F(*obj.Priority)
|
||||
}
|
||||
if obj.Comment != "" {
|
||||
param.Comment = cloudflare.F(obj.Comment)
|
||||
@@ -466,21 +457,6 @@ func (obj *CloudflareDNSRes) buildRecordParam() (any, error) {
|
||||
param := dns.NSRecordParam{
|
||||
Name: cloudflare.F(obj.RecordName),
|
||||
Type: cloudflare.F(dns.NSRecordTypeNS),
|
||||
Data: cloudflare.F(obj.Data),
|
||||
TTL: cloudflare.F(ttl),
|
||||
}
|
||||
if obj.Proxied != nil {
|
||||
param.Proxied = cloudflare.F(*obj.Proxied)
|
||||
}
|
||||
if obj.Comment != "" {
|
||||
param.Comment = cloudflare.F(obj.Comment)
|
||||
}
|
||||
return param, nil
|
||||
|
||||
case "SRV":
|
||||
param := dns.SRVRecordParam{
|
||||
Name: cloudflare.F(obj.RecordName),
|
||||
Type: cloudflare.F(dns.SRVRecordTypeSRV),
|
||||
Content: cloudflare.F(obj.Content),
|
||||
TTL: cloudflare.F(ttl),
|
||||
}
|
||||
@@ -593,12 +569,12 @@ func (obj *CloudflareDNSRes) needsUpdate(record dns.RecordResponse) bool {
|
||||
}
|
||||
|
||||
if obj.Priority != nil {
|
||||
if float64(*obj.Priority) != record.Priority {
|
||||
if *obj.Priority != record.Priority {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
if obj.Comment != record.Comment {
|
||||
if obj.Comment != "" && obj.Comment != record.Comment {
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -667,6 +643,9 @@ func (obj *CloudflareDNSRes) purgeCheckApply(ctx context.Context, apply bool) (b
|
||||
for _, record := range allRecords {
|
||||
recordKey := fmt.Sprintf("%s:%s:%s", record.Name, record.Type,
|
||||
record.Content)
|
||||
if record.Priority != 0 {
|
||||
recordKey = fmt.Sprintf("%s:%d", recordKey, record.Priority)
|
||||
}
|
||||
|
||||
if excludes[recordKey] {
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user