Skip to content

Commit

Permalink
Throw error when creating an ignored record
Browse files Browse the repository at this point in the history
  • Loading branch information
jungaretti committed Dec 4, 2022
1 parent 889382d commit c246a5f
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions pkg/providers/porkbun/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
}

Expand Down

0 comments on commit c246a5f

Please # to comment.