Skip to content

Commit c246a5f

Browse files
committedDec 4, 2022
Throw error when creating an ignored record
1 parent 889382d commit c246a5f

File tree

1 file changed

+16
-4
lines changed
  • pkg/providers/porkbun/api

1 file changed

+16
-4
lines changed
 

‎pkg/providers/porkbun/api/api.go

+16-4
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ func (p Api) CreateRecord(domain string, toCreate porkbun.Record) (string, error
5959
Id int `json:"id"`
6060
}
6161

62+
if isIgnored(toCreate) {
63+
return "", fmt.Errorf("cannot create an ignored record: %s", toCreate)
64+
}
65+
6266
request := createReq{
6367
Auth: p.Auth,
6468
Record: toCreate,
@@ -84,13 +88,21 @@ func (p Api) DeleteRecord(domain string, id string) error {
8488
return nil
8589
}
8690

91+
func isIgnored(record porkbun.Record) bool {
92+
if record.Type == "NS" {
93+
return true
94+
}
95+
if strings.HasPrefix(record.Name, "_acme-challenge") {
96+
return true
97+
}
98+
99+
return false
100+
}
101+
87102
func ignoreRecords(input []porkbun.Record) []porkbun.Record {
88103
records := make([]porkbun.Record, 0)
89104
for _, record := range input {
90-
if record.Type == "NS" {
91-
continue
92-
}
93-
if strings.HasPrefix(record.Name, "_acme-challenge") {
105+
if isIgnored(record) {
94106
continue
95107
}
96108

0 commit comments

Comments
 (0)