Skip to content

Commit

Permalink
do: maybe some good debugging?
Browse files Browse the repository at this point in the history
  • Loading branch information
kashalls committed May 24, 2024
1 parent 44d077a commit 2d47d02
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions dnsprovider/dnsprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"net/http"
"net/http/cookiejar"

log "github.com/sirupsen/logrus"
"sigs.k8s.io/external-dns/endpoint"
"sigs.k8s.io/external-dns/plan"
"sigs.k8s.io/external-dns/provider"
Expand Down Expand Up @@ -99,15 +100,15 @@ func (c *Client) setHeaders(req *http.Request) {
}

func (c *Client) GetData(url string) ([]byte, error) {

req, _ := http.NewRequest(http.MethodGet, fmt.Sprintf(url, c.BaseURL), nil)

c.setHeaders(req)

resp, err := c.HTTPClient.Do(req)
if err != nil {
return nil, err
}
log.Debugf("get data: %s", resp.Status)
log.Debugf("get data: %v", resp.Body)

if csrf := resp.Header.Get("x-csrf-token"); csrf != "" {
c.csrf = resp.Header.Get("x-csrf-token")
Expand All @@ -128,10 +129,11 @@ func (c *Client) ShipData(url string, body []byte) ([]byte, error) {
c.setHeaders(req)

resp, err := c.HTTPClient.Do(req)

if err != nil {
return nil, err
}
log.Debugf("post data: %s", resp.Status)
log.Debugf("post data: %v", resp.Body)

if csrf := resp.Header.Get("x-csrf-token"); csrf != "" {
c.csrf = resp.Header.Get("x-csrf-token")
Expand All @@ -155,6 +157,8 @@ func (c *Client) PutData(url string, body []byte) ([]byte, error) {
if err != nil {
return nil, err
}
log.Debugf("put data: %s", resp.Status)
log.Debugf("put data: %v", resp.Body)

if csrf := resp.Header.Get("x-csrf-token"); csrf != "" {
c.csrf = resp.Header.Get("x-csrf-token")
Expand All @@ -172,13 +176,14 @@ func (c *Client) PutData(url string, body []byte) ([]byte, error) {

func (c *Client) DeleteData(url string) ([]byte, error) {
req, _ := http.NewRequest(http.MethodPost, url, nil)

c.setHeaders(req)
resp, err := c.HTTPClient.Do(req)

resp, err := c.HTTPClient.Do(req)
if err != nil {
return nil, err
}
log.Debugf("delete data: %s", resp.Status)
log.Debugf("delete data: %v", resp.Body)

if csrf := resp.Header.Get("x-csrf-token"); csrf != "" {
c.csrf = resp.Header.Get("x-csrf-token")
Expand Down

0 comments on commit 2d47d02

Please sign in to comment.