From a3934e7b356acce4cb25dc161518a2dc9d49e9ce Mon Sep 17 00:00:00 2001 From: Tom Limoncelli Date: Sat, 25 Mar 2023 08:22:43 -0700 Subject: [PATCH] GCLOUD: Support ALIAS record type (#2225) Co-authored-by: Tom Limoncelli --- documentation/providers.md | 2 +- pkg/rejectif/label.go | 18 ++++++++++++++++++ providers/gcloud/auditrecords.go | 11 +++++++++-- providers/gcloud/gcloudProvider.go | 1 + 4 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 pkg/rejectif/label.go diff --git a/documentation/providers.md b/documentation/providers.md index 9f37b1ac7..1a3a3ff8f 100644 --- a/documentation/providers.md +++ b/documentation/providers.md @@ -31,7 +31,7 @@ If a feature is definitively not supported for whatever reason, we would also li | [`EASYNAME`](providers/easyname.md) | ❌ | ❌ | ✅ | ❔ | ❔ | ❔ | ❔ | ❔ | ❔ | ❔ | ❔ | ❔ | ❔ | ❔ | ❔ | ❌ | ✅ | ❔ | | [`EXOSCALE`](providers/exoscale.md) | ❌ | ✅ | ❌ | ✅ | ✅ | ❔ | ❌ | ❔ | ✅ | ❔ | ✅ | ❔ | ❌ | ❔ | ❌ | ❌ | ✅ | ❔ | | [`GANDI_V5`](providers/gandi_v5.md) | ❌ | ✅ | ✅ | ✅ | ✅ | ❔ | ❌ | ❔ | ✅ | ❔ | ✅ | ✅ | ✅ | ❌ | ❔ | ❌ | ❌ | ✅ | -| [`GCLOUD`](providers/gcloud.md) | ✅ | ✅ | ❌ | ❔ | ✅ | ❔ | ❌ | ❔ | ✅ | ❔ | ✅ | ✅ | ✅ | ❔ | ✅ | ✅ | ✅ | ✅ | +| [`GCLOUD`](providers/gcloud.md) | ✅ | ✅ | ❌ | ✅ | ✅ | ❔ | ❌ | ❔ | ✅ | ❔ | ✅ | ✅ | ✅ | ❔ | ✅ | ✅ | ✅ | ✅ | | [`GCORE`](providers/gcore.md) | ❌ | ✅ | ❌ | ❌ | ✅ | ❌ | ❌ | ❌ | ❌ | ❔ | ✅ | ❌ | ❌ | ❌ | ✅ | ✅ | ✅ | ✅ | | [`HEDNS`](providers/hedns.md) | ❌ | ✅ | ❌ | ✅ | ✅ | ❌ | ✅ | ✅ | ✅ | ❌ | ✅ | ✅ | ❌ | ❌ | ✅ | ✅ | ✅ | ✅ | | [`HETZNER`](providers/hetzner.md) | ❌ | ✅ | ❌ | ❌ | ✅ | ❔ | ❌ | ❔ | ❌ | ❔ | ✅ | ❌ | ✅ | ❌ | ✅ | ✅ | ✅ | ✅ | diff --git a/pkg/rejectif/label.go b/pkg/rejectif/label.go new file mode 100644 index 000000000..2e9c3baec --- /dev/null +++ b/pkg/rejectif/label.go @@ -0,0 +1,18 @@ +package rejectif + +import ( + "fmt" + + "github.com/StackExchange/dnscontrol/v3/models" +) + +// Keep these in alphabetical order. + +// LabelNotApex detects use not at apex. Use this when a record type +// is only permitted at the apex. +func LabelNotApex(rc *models.RecordConfig) error { + if rc.GetLabel() != "@" { + return fmt.Errorf("use not at apex") + } + return nil +} diff --git a/providers/gcloud/auditrecords.go b/providers/gcloud/auditrecords.go index 36beace3a..aadc8a3ac 100644 --- a/providers/gcloud/auditrecords.go +++ b/providers/gcloud/auditrecords.go @@ -1,10 +1,17 @@ package gcloud -import "github.com/StackExchange/dnscontrol/v3/models" +import ( + "github.com/StackExchange/dnscontrol/v3/models" + "github.com/StackExchange/dnscontrol/v3/pkg/rejectif" +) // 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 { - return nil + a := rejectif.Auditor{} + + a.Add("ALIAS", rejectif.LabelNotApex) // Last verified 2023-03-24 + + return a.Audit(records) } diff --git a/providers/gcloud/gcloudProvider.go b/providers/gcloud/gcloudProvider.go index 9b1c82eb7..62c72533c 100644 --- a/providers/gcloud/gcloudProvider.go +++ b/providers/gcloud/gcloudProvider.go @@ -23,6 +23,7 @@ import ( var features = providers.DocumentationNotes{ providers.CanGetZones: providers.Can(), + providers.CanUseAlias: providers.Can(), providers.CanUseCAA: providers.Can(), providers.CanUseDSForChildren: providers.Can(), providers.CanUseLOC: providers.Cannot(),