dnscontrol/providers/fortigate/auditrecords.go
2025-07-08 08:37:19 -04:00

39 lines
1.1 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package fortigate
import (
"fmt"
"github.com/StackExchange/dnscontrol/v4/models"
"strings"
)
// AuditRecords performs basic validation and returns warnings for known limitations.
func AuditRecords(records []*models.RecordConfig) []error {
var problems []error
for _, rc := range records {
switch rc.Type {
case "A", "AAAA", "CNAME":
// Supported no problem.
case "NS,PTR":
// FortiGate limitations: these record types are not fully supported.
problems = append(problems,
fmt.Errorf("record type %s is not supported by FortiGate provider (name: %s)", rc.Type, rc.GetLabelFQDN()))
default:
problems = append(problems,
fmt.Errorf("record type %s is not supported by FortiGate provider (name: %s)", rc.Type, rc.GetLabelFQDN()))
}
if rc.Type == "CNAME" && rc.GetLabel() == "@" {
problems = append(problems,
fmt.Errorf("CNAME at apex (@) is not allowed (name: %s)", rc.GetLabelFQDN()))
}
// Wildcard support
if strings.Contains(rc.GetLabelFQDN(), "*") {
problems = append(problems,
fmt.Errorf("wildcard record %s is not supported by FortiGate", rc.GetLabelFQDN()))
}
}
return problems
}