ns1: workaround an issue with ns1 API (#1671)

NS1 api returns a different message these days, which breaks error handling.

Until a fix is merged upstream, work around the issue by attempting to match the
stray error ourselves.

relates to #1667.
This commit is contained in:
Costas Drogos 2022-08-09 22:29:54 +02:00 committed by GitHub
parent eba4155cb9
commit dbfd2b7cb4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2,6 +2,7 @@ package ns1
import (
"encoding/json"
"errors"
"fmt"
"net/http"
"strconv"
@ -61,6 +62,12 @@ func (n *nsone) EnsureDomainExists(domain string) error {
return nil
}
newZoneExistsError := errors.New("invalid: FQDN already exists in the view")
if errors.As(err, &newZoneExistsError) {
// XXX: FIX: This is an ugly workaround for https://github.com/ns1/ns1-go/issues/163. Remove when resolved.
return nil
}
return err
}