vendor: update all dependencies

* Update all dependencies
  * Remove all `[[constraint]]` from Gopkg.toml
  * Add in the minimum number of `[[override]]` to build
  * Remove go get of github.com/inconshreveable/mousetrap as it is vendored
  * Update docs with new policy on constraints
This commit is contained in:
Nick Craig-Wood 2018-05-02 17:09:45 +01:00
parent 21383877df
commit 6427029c4e
4902 changed files with 1443417 additions and 227283 deletions

View file

@ -1,6 +1,22 @@
# Change Log
All notable changes to QingStor SDK for Go will be documented in this file.
## [v2.2.12] - 2018-4-8
### Changed
- Skip empty header while unpacking
## [v2.2.11] - 2018-3-28
### Changed
- Inject request id for HEAD request
### Fixed
- Fix a read timeout bug introduced in v2.2.10
## [v2.2.10] - 2018-3-14
### Changed
@ -134,6 +150,9 @@ All notable changes to QingStor SDK for Go will be documented in this file.
- QingStor SDK for the Go programming language.
[v2.2.12]: https://github.com/yunify/qingstor-sdk-go/compare/v2.2.11...v2.2.12
[v2.2.11]: https://github.com/yunify/qingstor-sdk-go/compare/v2.2.10...v2.2.11
[v2.2.10]: https://github.com/yunify/qingstor-sdk-go/compare/v2.2.9...v2.2.10
[v2.2.9]: https://github.com/yunify/qingstor-sdk-go/compare/v2.2.8...v2.2.9
[v2.2.8]: https://github.com/yunify/qingstor-sdk-go/compare/v2.2.7...v2.2.8
[v2.2.7]: https://github.com/yunify/qingstor-sdk-go/compare/v2.2.6...v2.2.7

View file

@ -28,7 +28,13 @@ help:
all: check build unit release
.PHONY: check
check: vet lint
check: vet lint format
.PHONY: format
format:
@echo "go fmt, skipping vendor packages"
@for pkg in ${PKGS_TO_CHECK}; do go fmt $${pkg}; done;
@echo "ok"
.PHONY: vet
vet:
@ -59,7 +65,7 @@ generate:
@echo "Done"
.PHONY: build
build:
build: format
@echo "Build the SDK"
go build ${PKGS_TO_RELEASE}
@echo "Done"

View file

@ -67,14 +67,14 @@ type HTTPClientSettings struct {
// IdleConnTimeout affects the time limit to re-use http connections
IdleConnTimeout time.Duration `yaml:"idle_timeout"`
TCPKeepAlive time.Duration `yaml:"tcp_keepalive_time"`
TCPKeepAlive time.Duration `yaml:"tcp_keepalive_time"`
DualStack bool `yaml:"dual_stack"`
DualStack bool `yaml:"dual_stack"`
// MaxIdleConns affects the idle connections kept for re-use
MaxIdleConns int `yaml:"max_idle_conns"`
MaxIdleConns int `yaml:"max_idle_conns"`
MaxIdleConnsPerHost int `yaml:"max_idle_conns_per_host"`
MaxIdleConnsPerHost int `yaml:"max_idle_conns_per_host"`
ExpectContinueTimeout time.Duration `yaml:"expect_continue_timeout"`
}

View file

@ -19,10 +19,8 @@ package builder
import (
"encoding/json"
"errors"
"fmt"
"io"
"net/http"
"net/url"
"reflect"
"strconv"
"strings"
@ -239,20 +237,10 @@ func (b *BaseBuilder) setupHeaders(httpRequest *http.Request) error {
if b.parsedHeaders != nil {
for headerKey, headerValue := range *b.parsedHeaders {
if headerKey == "X-QS-Fetch-Source" {
// header X-QS-Fetch-Source is a URL to fetch.
// We should first parse this URL.
requestURL, err := url.Parse(headerValue)
if err != nil {
return fmt.Errorf("invalid HTTP header value: %s", headerValue)
}
headerValue = requestURL.String()
} else {
for _, r := range headerValue {
if r > unicode.MaxASCII {
headerValue = utils.URLQueryEscape(headerValue)
break
}
for _, r := range headerValue {
if r > unicode.MaxASCII {
headerValue = utils.URLQueryEscape(headerValue)
break
}
}

View file

@ -154,6 +154,14 @@ func (qb *QingStorBuilder) setupHeaders(httpRequest *http.Request) error {
httpRequest.Header.Set("User-Agent", ua)
}
if s := httpRequest.Header.Get("X-QS-Fetch-Source"); s != "" {
u, err := url.Parse(s)
if err != nil {
return fmt.Errorf("invalid HTTP header value: %s", s)
}
httpRequest.Header.Set("X-QS-Fetch-Source", u.String())
}
if qb.baseBuilder.operation.APIName == "Delete Multiple Objects" {
buffer := &bytes.Buffer{}
buffer.ReadFrom(httpRequest.Body)

View file

@ -96,6 +96,11 @@ func (b *BaseUnpacker) parseResponseHeaders() error {
fieldTagLocation := fields.Type().Field(i).Tag.Get("location")
fieldStringValue := b.httpResponse.Header.Get(fieldTagName)
// Empty value should be ignored.
if fieldStringValue == "" {
continue
}
if fieldTagName != "" && fieldTagLocation == "headers" {
switch field.Interface().(type) {
case *string:

View file

@ -72,6 +72,9 @@ func (qu *QingStorUnpacker) parseError() error {
}
}
qsError.StatusCode = qu.baseUnpacker.httpResponse.StatusCode
if qsError.RequestID == "" {
qsError.RequestID = qu.baseUnpacker.httpResponse.Header.Get(http.CanonicalHeaderKey("X-QS-Request-ID"))
}
return qsError
}

View file

@ -21,10 +21,12 @@ import (
"io/ioutil"
"net/http"
"reflect"
"strings"
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/yunify/qingstor-sdk-go/request/data"
"github.com/yunify/qingstor-sdk-go/request/errors"
)
@ -122,3 +124,27 @@ func TestQingStorUnpacker_UnpackHTTPRequestWithError(t *testing.T) {
assert.Equal(t, "aa08cf7a43f611e5886952542e6ce14b", e.RequestID)
}
}
func TestQingStorUnpacker_UnpackHeadHTTPRequestWithError(t *testing.T) {
type HeadBucketsOutput struct {
StatusCode *int `location:"statusCode"`
Error *errors.QingStorError
RequestID *string `location:"requestID"`
}
httpResponse := &http.Response{Header: http.Header{}}
httpResponse.StatusCode = 404
httpResponse.Header.Set("Content-Type", "application/json")
httpResponse.Header.Set("X-QS-Request-ID", "aa08cf7a43f611e5886952542e6ce14b")
httpResponse.Body = ioutil.NopCloser(strings.NewReader(""))
output := &HeadBucketsOutput{}
outputValue := reflect.ValueOf(output)
unpacker := QingStorUnpacker{}
err := unpacker.UnpackHTTPRequest(&data.Operation{}, httpResponse, &outputValue)
assert.NotNil(t, err)
switch e := err.(type) {
case *errors.QingStorError:
assert.Equal(t, "aa08cf7a43f611e5886952542e6ce14b", e.RequestID)
}
}

View file

@ -20,4 +20,4 @@
package sdk
// Version number.
const Version = "2.2.10"
const Version = "2.2.12"