Skip to content

Commit

Permalink
Merge pull request #112 from akamai/release/2.0.0
Browse files Browse the repository at this point in the history
Release/2.0.1
  • Loading branch information
zstlaw authored Oct 20, 2020
2 parents 776a71a + c66c8ba commit 6fa063a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
10 changes: 5 additions & 5 deletions pkg/configdns/record_lookup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func TestDns_GetRecordList(t *testing.T) {
}
]
}`,
expectedPath: "/config-dns/v2/zones/example.com/recordsets?types=A&showAll=true",
expectedPath: "/config-dns/v2/zones/example.com/recordsets?showAll=true&types=A",
expectedResponse: &RecordSetResponse{
Metadata: MetadataH{
LastPage: 0,
Expand Down Expand Up @@ -158,7 +158,7 @@ func TestDns_GetRecordList(t *testing.T) {
"detail": "Error fetching authorities",
"status": 500
}`,
expectedPath: "/config-dns/v2/zones/example.com/recordsets?types=A&showAll=true",
expectedPath: "/config-dns/v2/zones/example.com/recordsets?showAll=true&types=A",
withError: &Error{
Type: "internal_error",
Title: "Internal Server Error",
Expand Down Expand Up @@ -227,7 +227,7 @@ func TestDns_GetRdata(t *testing.T) {
}
]
}`,
expectedPath: "/config-dns/v2/zones/example.com/recordsets?types=AAAA&showAll=true",
expectedPath: "/config-dns/v2/zones/example.com/recordsets?showAll=true&types=AAAA",
expectedResponse: []string{"2001:0db8:85a3:0000:0000:8a2e:0370:7334"},
},
"loc test": {
Expand Down Expand Up @@ -257,7 +257,7 @@ func TestDns_GetRdata(t *testing.T) {
}
]
}`,
expectedPath: "/config-dns/v2/zones/example.com/recordsets?types=LOC&showAll=true",
expectedPath: "/config-dns/v2/zones/example.com/recordsets?showAll=true&types=LOC",
expectedResponse: []string{"52 22 23.000 N 4 53 32.000 E -2.00m 0.00m 10000.00m 10.00m"},
},
"500 internal server error": {
Expand All @@ -271,7 +271,7 @@ func TestDns_GetRdata(t *testing.T) {
"detail": "Error fetching authorities",
"status": 500
}`,
expectedPath: "/config-dns/v2/zones/example.com/recordsets?types=A&showAll=true",
expectedPath: "/config-dns/v2/zones/example.com/recordsets?showAll=true&types=A",
withError: &Error{
Type: "internal_error",
Title: "Internal Server Error",
Expand Down
2 changes: 1 addition & 1 deletion pkg/configdns/zone.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ var zoneStructMap map[string]string = map[string]string{
"SignAndServeAlgorithm": "signAndServeAlgorithm",
"TsigKey": "tsigKey",
"Target": "target",
"EndCustomerId": "endCustomerId",
"EndCustomerID": "endCustomerId",
"ContractId": "contractId"}

// Util to convert struct to http request body, eg. io.reader
Expand Down
5 changes: 3 additions & 2 deletions pkg/configgtm/datacenter.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"net/http"

"strconv"
"strings"
)

//
Expand Down Expand Up @@ -209,7 +208,9 @@ func createDefaultDC(ctx context.Context, p *gtm, defaultID int, domainName stri
if err == nil {
return dc, err
} else {
if !strings.Contains(err.Error(), "not found") || !strings.Contains(err.Error(), "Datacenter") {
apiError, ok := err.(*Error)
//if !strings.Contains(err.Error(), "not found") || !strings.Contains(err.Error(), "Datacenter") {
if !ok || apiError.StatusCode != http.StatusNotFound {
return nil, err
}
}
Expand Down
4 changes: 3 additions & 1 deletion pkg/session/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ func (s *session) Exec(r *http.Request, out interface{}, in ...interface{}) (*ht
}
}

if out != nil {
if out != nil &&
resp.StatusCode >= http.StatusOK && resp.StatusCode < http.StatusMultipleChoices &&
resp.StatusCode != http.StatusNoContent && resp.StatusCode != http.StatusResetContent {
data, err := ioutil.ReadAll(resp.Body)
resp.Body = ioutil.NopCloser(bytes.NewBuffer(data))
if err != nil {
Expand Down

0 comments on commit 6fa063a

Please sign in to comment.