From c246a5f3c53afc40e60b924061883139add3c79f Mon Sep 17 00:00:00 2001 From: JP Ungaretti Date: Sun, 4 Dec 2022 06:13:28 +0000 Subject: [PATCH] Throw error when creating an ignored record --- pkg/providers/porkbun/api/api.go | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/pkg/providers/porkbun/api/api.go b/pkg/providers/porkbun/api/api.go index 7364eb3..3ae861b 100644 --- a/pkg/providers/porkbun/api/api.go +++ b/pkg/providers/porkbun/api/api.go @@ -59,6 +59,10 @@ func (p Api) CreateRecord(domain string, toCreate porkbun.Record) (string, error Id int `json:"id"` } + if isIgnored(toCreate) { + return "", fmt.Errorf("cannot create an ignored record: %s", toCreate) + } + request := createReq{ Auth: p.Auth, Record: toCreate, @@ -84,13 +88,21 @@ func (p Api) DeleteRecord(domain string, id string) error { return nil } +func isIgnored(record porkbun.Record) bool { + if record.Type == "NS" { + return true + } + if strings.HasPrefix(record.Name, "_acme-challenge") { + return true + } + + return false +} + func ignoreRecords(input []porkbun.Record) []porkbun.Record { records := make([]porkbun.Record, 0) for _, record := range input { - if record.Type == "NS" { - continue - } - if strings.HasPrefix(record.Name, "_acme-challenge") { + if isIgnored(record) { continue }