2021-03-08 02:19:22 +08:00
|
|
|
package route53
|
|
|
|
|
2023-03-01 23:00:58 +08:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
2023-05-21 01:21:45 +08:00
|
|
|
"github.com/StackExchange/dnscontrol/v4/models"
|
|
|
|
"github.com/StackExchange/dnscontrol/v4/pkg/rejectif"
|
2023-03-01 23:00:58 +08:00
|
|
|
)
|
2021-03-08 02:19:22 +08:00
|
|
|
|
2022-08-12 05:24:47 +08:00
|
|
|
// AuditRecords returns a list of errors corresponding to the records
|
|
|
|
// that aren't supported by this provider. If all records are
|
|
|
|
// supported, an empty list is returned.
|
|
|
|
func AuditRecords(records []*models.RecordConfig) []error {
|
2023-03-01 23:00:58 +08:00
|
|
|
a := rejectif.Auditor{}
|
|
|
|
|
|
|
|
a.Add("R53_ALIAS", rejectifTargetEqualsLabel) // Last verified 2023-03-01
|
|
|
|
|
|
|
|
return a.Audit(records)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Normally this kind of function would be put in `pkg/rejectif` but
|
|
|
|
// since this is ROUTE53-specific, we'll include it here.
|
|
|
|
|
|
|
|
// rejectifTargetEqualsLabel rejects an ALIAS that would create a loop.
|
|
|
|
|
|
|
|
func rejectifTargetEqualsLabel(rc *models.RecordConfig) error {
|
|
|
|
if (rc.GetLabelFQDN() + ".") == rc.GetTargetField() {
|
|
|
|
return fmt.Errorf("alias target loop")
|
|
|
|
}
|
2021-03-08 02:19:22 +08:00
|
|
|
return nil
|
|
|
|
}
|