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).
|
// Type (e.g., IP address for A records, hostname for CNAME records).
|
||||||
Content string `lang:"content"`
|
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
|
// 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
|
// records). This is a pointer to distinguish between an unset value and
|
||||||
// a zero value.
|
// a zero value.
|
||||||
Priority *int64 `lang:"priority"`
|
Priority *float64 `lang:"priority"`
|
||||||
|
|
||||||
// Proxied specifies whether the record should be proxied through
|
// Proxied specifies whether the record should be proxied through
|
||||||
// Cloudflare's CDN. This is a pointer to distinguish between an unset
|
// Cloudflare's CDN. This is a pointer to distinguish between an unset
|
||||||
@@ -164,7 +160,7 @@ func (obj *CloudflareDNSRes) Validate() error {
|
|||||||
// cloudflare accepts ~4req/s so this is safe enough even when managing lots
|
// cloudflare accepts ~4req/s so this is safe enough even when managing lots
|
||||||
// of records
|
// of records
|
||||||
if obj.MetaParams().Poll == 0 || obj.MetaParams().Poll < 60 {
|
if obj.MetaParams().Poll == 0 || obj.MetaParams().Poll < 60 {
|
||||||
return fmt.Errorf("cloudflare:dns requires polling, set Meta:poll param (e.g., 300s), min. 60s")
|
return fmt.Errorf("cloudflare:dns requires polling, set Meta:poll param (e.g., 300s), min. 60s")
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@@ -179,7 +175,6 @@ func (obj *CloudflareDNSRes) Init(init *engine.Init) error {
|
|||||||
option.WithAPIToken(obj.APIToken),
|
option.WithAPIToken(obj.APIToken),
|
||||||
)
|
)
|
||||||
|
|
||||||
//TODO: does it make more sense to check it here or in CheckApply()?
|
|
||||||
zoneListParams := zones.ZoneListParams{
|
zoneListParams := zones.ZoneListParams{
|
||||||
Name: cloudflare.F(obj.Zone),
|
Name: cloudflare.F(obj.Zone),
|
||||||
}
|
}
|
||||||
@@ -365,14 +360,10 @@ func (obj *CloudflareDNSRes) Cmp(r engine.Res) error {
|
|||||||
return fmt.Errorf("the priority param differs")
|
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")
|
return fmt.Errorf("the priority param differs")
|
||||||
}
|
}
|
||||||
|
|
||||||
if obj.Data != res.Data {
|
|
||||||
return fmt.Errorf("the data param differs")
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -440,7 +431,7 @@ func (obj *CloudflareDNSRes) buildRecordParam() (any, error) {
|
|||||||
param.Proxied = cloudflare.F(*obj.Proxied)
|
param.Proxied = cloudflare.F(*obj.Proxied)
|
||||||
}
|
}
|
||||||
if obj.Priority != nil { // required for MX record
|
if obj.Priority != nil { // required for MX record
|
||||||
param.Priority = cloudflare.F(float64(*obj.Priority))
|
param.Priority = cloudflare.F(*obj.Priority)
|
||||||
}
|
}
|
||||||
if obj.Comment != "" {
|
if obj.Comment != "" {
|
||||||
param.Comment = cloudflare.F(obj.Comment)
|
param.Comment = cloudflare.F(obj.Comment)
|
||||||
@@ -464,23 +455,8 @@ func (obj *CloudflareDNSRes) buildRecordParam() (any, error) {
|
|||||||
|
|
||||||
case "NS":
|
case "NS":
|
||||||
param := dns.NSRecordParam{
|
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),
|
Name: cloudflare.F(obj.RecordName),
|
||||||
Type: cloudflare.F(dns.SRVRecordTypeSRV),
|
Type: cloudflare.F(dns.NSRecordTypeNS),
|
||||||
Content: cloudflare.F(obj.Content),
|
Content: cloudflare.F(obj.Content),
|
||||||
TTL: cloudflare.F(ttl),
|
TTL: cloudflare.F(ttl),
|
||||||
}
|
}
|
||||||
@@ -593,12 +569,12 @@ func (obj *CloudflareDNSRes) needsUpdate(record dns.RecordResponse) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if obj.Priority != nil {
|
if obj.Priority != nil {
|
||||||
if float64(*obj.Priority) != record.Priority {
|
if *obj.Priority != record.Priority {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if obj.Comment != record.Comment {
|
if obj.Comment != "" && obj.Comment != record.Comment {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -667,6 +643,9 @@ func (obj *CloudflareDNSRes) purgeCheckApply(ctx context.Context, apply bool) (b
|
|||||||
for _, record := range allRecords {
|
for _, record := range allRecords {
|
||||||
recordKey := fmt.Sprintf("%s:%s:%s", record.Name, record.Type,
|
recordKey := fmt.Sprintf("%s:%s:%s", record.Name, record.Type,
|
||||||
record.Content)
|
record.Content)
|
||||||
|
if record.Priority != 0 {
|
||||||
|
recordKey = fmt.Sprintf("%s:%d", recordKey, record.Priority)
|
||||||
|
}
|
||||||
|
|
||||||
if excludes[recordKey] {
|
if excludes[recordKey] {
|
||||||
continue
|
continue
|
||||||
|
|||||||
Reference in New Issue
Block a user