vendor: update qingstor

dep ensure needed to do this, probably after various vendor merges
This commit is contained in:
Nick Craig-Wood 2017-08-08 10:18:33 +01:00
parent ec2ea37ad2
commit c1bfdd893f
50 changed files with 777 additions and 229 deletions

18
Gopkg.lock generated
View file

@ -13,12 +13,6 @@
revision = "a5913b3f7deecba45e98ff33cefbac4fd204ddd7" revision = "a5913b3f7deecba45e98ff33cefbac4fd204ddd7"
version = "v0.10.0" version = "v0.10.0"
[[projects]]
name = "github.com/Sirupsen/logrus"
packages = ["."]
revision = "202f25545ea4cf9b191ff7f846df5d87c9382c2b"
version = "v1.0.0"
[[projects]] [[projects]]
name = "github.com/Azure/azure-sdk-for-go" name = "github.com/Azure/azure-sdk-for-go"
packages = ["storage"] packages = ["storage"]
@ -199,6 +193,12 @@
packages = ["."] packages = ["."]
revision = "541ff5ee47f1dddf6a5281af78307d921524bcb5" revision = "541ff5ee47f1dddf6a5281af78307d921524bcb5"
[[projects]]
name = "github.com/sirupsen/logrus"
packages = ["."]
revision = "a3f95b5c423586578a4e099b11a46c2479628cac"
version = "1.0.2"
[[projects]] [[projects]]
branch = "master" branch = "master"
name = "github.com/skratchdot/open-golang" name = "github.com/skratchdot/open-golang"
@ -232,8 +232,8 @@
[[projects]] [[projects]]
name = "github.com/yunify/qingstor-sdk-go" name = "github.com/yunify/qingstor-sdk-go"
packages = [".","config","logger","request","request/builder","request/data","request/errors","request/signer","request/unpacker","service","utils"] packages = [".","config","logger","request","request/builder","request/data","request/errors","request/signer","request/unpacker","service","utils"]
revision = "26f2cc6f249f4c2a08ed89f1d7d566a463c1dfc2" revision = "68ce7c233bde780b2bbe1e1cf018db8e2df86361"
version = "v2.2.5" version = "v2.2.6"
[[projects]] [[projects]]
branch = "master" branch = "master"
@ -292,6 +292,6 @@
[solve-meta] [solve-meta]
analyzer-name = "dep" analyzer-name = "dep"
analyzer-version = 1 analyzer-version = 1
inputs-digest = "904bc0ea1f770b0473b24560dc0d24c5c647971e959e58538799c5cad1eaa97e" inputs-digest = "0b3a6116075cedb5990bd6edb0e5cfdaa04c7b28462a9c6cb02b8cbb63a2dab6"
solver-name = "gps-cdcl" solver-name = "gps-cdcl"
solver-version = 1 solver-version = 1

View file

@ -10,4 +10,3 @@ install:
- go get github.com/stretchr/testify/assert - go get github.com/stretchr/testify/assert
script: script:
- go test -race -v . - go test -race -v .
- cd hooks/null && go test -race -v .

View file

@ -1,3 +1,12 @@
# 1.0.2
* bug: quote non-string values in text formatter (#583)
* Make (*Logger) SetLevel a public method
# 1.0.1
* bug: fix escaping in text formatter (#575)
# 1.0.0 # 1.0.0
* Officially changed name to lower-case * Officially changed name to lower-case

View file

@ -1,22 +1,24 @@
# Logrus <img src="http://i.imgur.com/hTeVwmJ.png" width="40" height="40" alt=":walrus:" class="emoji" title=":walrus:"/>&nbsp;[![Build Status](https://travis-ci.org/sirupsen/logrus.svg?branch=master)](https://travis-ci.org/sirupsen/logrus)&nbsp;[![GoDoc](https://godoc.org/github.com/sirupsen/logrus?status.svg)](https://godoc.org/github.com/sirupsen/logrus) # Logrus <img src="http://i.imgur.com/hTeVwmJ.png" width="40" height="40" alt=":walrus:" class="emoji" title=":walrus:"/>&nbsp;[![Build Status](https://travis-ci.org/sirupsen/logrus.svg?branch=master)](https://travis-ci.org/sirupsen/logrus)&nbsp;[![GoDoc](https://godoc.org/github.com/sirupsen/logrus?status.svg)](https://godoc.org/github.com/sirupsen/logrus)
Logrus is a structured logger for Go (golang), completely API compatible with Logrus is a structured logger for Go (golang), completely API compatible with
the standard library logger. [Godoc][godoc]. **Please note the Logrus API is not the standard library logger. [Godoc][godoc].
yet stable (pre 1.0). Logrus itself is completely stable and has been used in
many large deployments. The core API is unlikely to change much but please
version control your Logrus to make sure you aren't fetching latest `master` on
every build.**
**Seeing weird case-sensitive problems?** Unfortunately, the author failed to **Seeing weird case-sensitive problems?** It's in the past been possible to
realize the consequences of renaming to lower-case. Due to the Go package import Logrus as both upper- and lower-case. Due to the Go package environment,
environment, this caused issues. Regretfully, there's no turning back now. this caused issues in the community and we needed a standard. Some environments
experienced problems with the upper-case variant, so the lower-case was decided.
Everything using `logrus` will need to use the lower-case: Everything using `logrus` will need to use the lower-case:
`github.com/sirupsen/logrus`. Any package that isn't, should be changed. `github.com/sirupsen/logrus`. Any package that isn't, should be changed.
I am terribly sorry for this inconvenience. Logrus strives hard for backwards To fix Glide, see [these
compatibility, and the author failed to realize the cascading consequences of
such a name-change. To fix Glide, see [these
comments](https://github.com/sirupsen/logrus/issues/553#issuecomment-306591437). comments](https://github.com/sirupsen/logrus/issues/553#issuecomment-306591437).
For an in-depth explanation of the casing issue, see [this
comment](https://github.com/sirupsen/logrus/issues/570#issuecomment-313933276).
**Are you interested in assisting in maintaining Logrus?** Currently I have a
lot of obligations, and I am unable to provide Logrus with the maintainership it
needs. If you'd like to help, please reach out to me at `simon at author's
username dot com`.
Nicely color-coded in development (when a TTY is attached, otherwise just Nicely color-coded in development (when a TTY is attached, otherwise just
plain text): plain text):
@ -266,6 +268,7 @@ Note: Syslog hook also support connecting to local syslog (Ex. "/dev/log" or "/v
| [Logrusly](https://github.com/sebest/logrusly) | Send logs to [Loggly](https://www.loggly.com/) | | [Logrusly](https://github.com/sebest/logrusly) | Send logs to [Loggly](https://www.loggly.com/) |
| [Logstash](https://github.com/bshuster-repo/logrus-logstash-hook) | Hook for logging to [Logstash](https://www.elastic.co/products/logstash) | | [Logstash](https://github.com/bshuster-repo/logrus-logstash-hook) | Hook for logging to [Logstash](https://www.elastic.co/products/logstash) |
| [Mail](https://github.com/zbindenren/logrus_mail) | Hook for sending exceptions via mail | | [Mail](https://github.com/zbindenren/logrus_mail) | Hook for sending exceptions via mail |
| [Mattermost](https://github.com/shuLhan/mattermost-integration/tree/master/hooks/logrus) | Hook for logging to [Mattermost](https://mattermost.com/) |
| [Mongodb](https://github.com/weekface/mgorus) | Hook for logging to mongodb | | [Mongodb](https://github.com/weekface/mgorus) | Hook for logging to mongodb |
| [NATS-Hook](https://github.com/rybit/nats_logrus_hook) | Hook for logging to [NATS](https://nats.io) | | [NATS-Hook](https://github.com/rybit/nats_logrus_hook) | Hook for logging to [NATS](https://nats.io) |
| [Octokit](https://github.com/dorajistyle/logrus-octokit-hook) | Hook for logging to github via octokit | | [Octokit](https://github.com/dorajistyle/logrus-octokit-hook) | Hook for logging to github via octokit |
@ -280,7 +283,7 @@ Note: Syslog hook also support connecting to local syslog (Ex. "/dev/log" or "/v
| [Slackrus](https://github.com/johntdyer/slackrus) | Hook for Slack chat. | | [Slackrus](https://github.com/johntdyer/slackrus) | Hook for Slack chat. |
| [Stackdriver](https://github.com/knq/sdhook) | Hook for logging to [Google Stackdriver](https://cloud.google.com/logging/) | | [Stackdriver](https://github.com/knq/sdhook) | Hook for logging to [Google Stackdriver](https://cloud.google.com/logging/) |
| [Sumorus](https://github.com/doublefree/sumorus) | Hook for logging to [SumoLogic](https://www.sumologic.com/)| | [Sumorus](https://github.com/doublefree/sumorus) | Hook for logging to [SumoLogic](https://www.sumologic.com/)|
| [Syslog](https://github.com/Sirupsen/logrus/blob/master/hooks/syslog/syslog.go) | Send errors to remote syslog server. Uses standard library `log/syslog` behind the scenes. | | [Syslog](https://github.com/sirupsen/logrus/blob/master/hooks/syslog/syslog.go) | Send errors to remote syslog server. Uses standard library `log/syslog` behind the scenes. |
| [Syslog TLS](https://github.com/shinji62/logrus-syslog-ng) | Send errors to remote syslog server with TLS support. | | [Syslog TLS](https://github.com/shinji62/logrus-syslog-ng) | Send errors to remote syslog server with TLS support. |
| [TraceView](https://github.com/evalphobia/logrus_appneta) | Hook for logging to [AppNeta TraceView](https://www.appneta.com/products/traceview/) | | [TraceView](https://github.com/evalphobia/logrus_appneta) | Hook for logging to [AppNeta TraceView](https://www.appneta.com/products/traceview/) |
| [Typetalk](https://github.com/dragon3/logrus-typetalk-hook) | Hook for logging to [Typetalk](https://www.typetalk.in/) | | [Typetalk](https://github.com/dragon3/logrus-typetalk-hook) | Hook for logging to [Typetalk](https://www.typetalk.in/) |
@ -449,13 +452,13 @@ Logrus has a built in facility for asserting the presence of log messages. This
```go ```go
import( import(
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"github.com/sirupsen/logrus/hooks/null" "github.com/sirupsen/logrus/hooks/test"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"testing" "testing"
) )
func TestSomething(t*testing.T){ func TestSomething(t*testing.T){
logger, hook := null.NewNullLogger() logger, hook := test.NewNullLogger()
logger.Error("Helloerror") logger.Error("Helloerror")
assert.Equal(t, 1, len(hook.Entries)) assert.Equal(t, 1, len(hook.Entries))

View file

@ -31,7 +31,7 @@ func SetFormatter(formatter Formatter) {
func SetLevel(level Level) { func SetLevel(level Level) {
std.mu.Lock() std.mu.Lock()
defer std.mu.Unlock() defer std.mu.Unlock()
std.setLevel(level) std.SetLevel(level)
} }
// GetLevel returns the standard logger level. // GetLevel returns the standard logger level.

View file

@ -312,6 +312,6 @@ func (logger *Logger) level() Level {
return Level(atomic.LoadUint32((*uint32)(&logger.Level))) return Level(atomic.LoadUint32((*uint32)(&logger.Level)))
} }
func (logger *Logger) setLevel(level Level) { func (logger *Logger) SetLevel(level Level) {
atomic.StoreUint32((*uint32)(&logger.Level), uint32(level)) atomic.StoreUint32((*uint32)(&logger.Level), uint32(level))
} }

View file

@ -14,7 +14,7 @@ const (
red = 31 red = 31
green = 32 green = 32
yellow = 33 yellow = 33
blue = 34 blue = 36
gray = 37 gray = 37
) )
@ -153,7 +153,7 @@ func (f *TextFormatter) needsQuoting(text string) bool {
if !((ch >= 'a' && ch <= 'z') || if !((ch >= 'a' && ch <= 'z') ||
(ch >= 'A' && ch <= 'Z') || (ch >= 'A' && ch <= 'Z') ||
(ch >= '0' && ch <= '9') || (ch >= '0' && ch <= '9') ||
ch == '-' || ch == '.') { ch == '-' || ch == '.' || ch == '_' || ch == '/' || ch == '@' || ch == '^' || ch == '+') {
return true return true
} }
} }
@ -169,21 +169,21 @@ func (f *TextFormatter) appendKeyValue(b *bytes.Buffer, key string, value interf
} }
func (f *TextFormatter) appendValue(b *bytes.Buffer, value interface{}) { func (f *TextFormatter) appendValue(b *bytes.Buffer, value interface{}) {
switch value := value.(type) { stringVal, ok := value.(string)
case string: if !ok {
if !f.needsQuoting(value) { stringVal = fmt.Sprint(value)
b.WriteString(value) }
} else {
fmt.Fprintf(b, "%s%v%s", f.QuoteCharacter, value, f.QuoteCharacter) if !f.needsQuoting(stringVal) {
} b.WriteString(stringVal)
case error: } else {
errmsg := value.Error() b.WriteString(f.quoteString(stringVal))
if !f.needsQuoting(errmsg) {
b.WriteString(errmsg)
} else {
fmt.Fprintf(b, "%s%v%s", f.QuoteCharacter, errmsg, f.QuoteCharacter)
}
default:
fmt.Fprint(b, value)
} }
} }
func (f *TextFormatter) quoteString(v string) string {
escapedQuote := fmt.Sprintf("\\%s", f.QuoteCharacter)
escapedValue := strings.Replace(v, f.QuoteCharacter, escapedQuote, -1)
return fmt.Sprintf("%s%v%s", f.QuoteCharacter, escapedValue, f.QuoteCharacter)
}

View file

@ -6,6 +6,7 @@ import (
"strings" "strings"
"testing" "testing"
"time" "time"
"fmt"
) )
func TestQuoting(t *testing.T) { func TestQuoting(t *testing.T) {
@ -28,7 +29,13 @@ func TestQuoting(t *testing.T) {
checkQuoting(false, "abcd") checkQuoting(false, "abcd")
checkQuoting(false, "v1.0") checkQuoting(false, "v1.0")
checkQuoting(false, "1234567890") checkQuoting(false, "1234567890")
checkQuoting(true, "/foobar") checkQuoting(false, "/foobar")
checkQuoting(false, "foo_bar")
checkQuoting(false, "foo@bar")
checkQuoting(false, "foobar^")
checkQuoting(false, "+/-_^@f.oobar")
checkQuoting(true, "foobar$")
checkQuoting(true, "&foobar")
checkQuoting(true, "x y") checkQuoting(true, "x y")
checkQuoting(true, "x,y") checkQuoting(true, "x,y")
checkQuoting(false, errors.New("invalid")) checkQuoting(false, errors.New("invalid"))
@ -38,7 +45,12 @@ func TestQuoting(t *testing.T) {
tf.QuoteCharacter = "`" tf.QuoteCharacter = "`"
checkQuoting(false, "") checkQuoting(false, "")
checkQuoting(false, "abcd") checkQuoting(false, "abcd")
checkQuoting(true, "/foobar") checkQuoting(false, "/foobar")
checkQuoting(false, "foo_bar")
checkQuoting(false, "foo@bar")
checkQuoting(false, "foobar^")
checkQuoting(true, "foobar$")
checkQuoting(true, "&foobar")
checkQuoting(true, errors.New("invalid argument")) checkQuoting(true, errors.New("invalid argument"))
// Test for multi-character quotes. // Test for multi-character quotes.
@ -53,6 +65,68 @@ func TestQuoting(t *testing.T) {
checkQuoting(true, errors.New("invalid argument")) checkQuoting(true, errors.New("invalid argument"))
} }
func TestEscaping_DefaultQuoteCharacter(t *testing.T) {
tf := &TextFormatter{DisableColors: true}
testCases := []struct {
value string
expected string
}{
{`ba"r`, `ba\"r`},
{`ba'r`, `ba'r`},
}
for _, tc := range testCases {
b, _ := tf.Format(WithField("test", tc.value))
if !bytes.Contains(b, []byte(tc.expected)) {
t.Errorf("escaping expected for %q (result was %q instead of %q)", tc.value, string(b), tc.expected)
}
}
}
func TestEscaping_Interface(t *testing.T) {
tf := &TextFormatter{DisableColors: true}
ts := time.Now()
testCases := []struct {
value interface{}
expected string
}{
{ts, fmt.Sprintf("\"%s\"", ts.String())},
{errors.New("error: something went wrong"), "\"error: something went wrong\""},
}
for _, tc := range testCases {
b, _ := tf.Format(WithField("test", tc.value))
if !bytes.Contains(b, []byte(tc.expected)) {
t.Errorf("escaping expected for %q (result was %q instead of %q)", tc.value, string(b), tc.expected)
}
}
}
func TestEscaping_CustomQuoteCharacter(t *testing.T) {
tf := &TextFormatter{DisableColors: true}
testCases := []struct {
value string
expected string
quoteChar string
}{
{`ba"r`, `ba"r`, `'`},
{`ba'r`, `ba\'r`, `'`},
{`ba'r`, `ba'r`, `^`},
}
for _, tc := range testCases {
tf.QuoteCharacter = tc.quoteChar
b, _ := tf.Format(WithField("test", tc.value))
if !bytes.Contains(b, []byte(tc.expected)) {
t.Errorf("escaping expected for %q (result was %q instead of %q)", tc.value, string(b), tc.expected)
}
}
}
func TestTimestampFormat(t *testing.T) { func TestTimestampFormat(t *testing.T) {
checkTimeStr := func(format string) { checkTimeStr := func(format string) {
customFormatter := &TextFormatter{DisableColors: true, TimestampFormat: format} customFormatter := &TextFormatter{DisableColors: true, TimestampFormat: format}

View file

@ -32,12 +32,19 @@ before_install:
mv linux-amd64 glide-v0.12.3; mv linux-amd64 glide-v0.12.3;
fi fi
- pushd glide-v0.12.3 && sudo cp glide /usr/local/bin && popd - pushd glide-v0.12.3 && sudo cp glide /usr/local/bin && popd
- if [[ ! -d "./snips-v0.1.0" ]]; then
wget https://github.com/yunify/snips/releases/download/v0.1.0/snips-v0.1.0-linux_amd64.tar.gz &&
mkdir snips-v0.1.0 &&
pushd snips-v0.1.0 &&
tar -vxzf ../snips-v0.1.0-linux_amd64.tar.gz &&
popd;
fi
- pushd snips-v0.1.0 && sudo cp snips /usr/local/bin && popd
- popd - popd
- /usr/local/bin/make --version - /usr/local/bin/make --version
- /usr/local/bin/glide --version - /usr/local/bin/glide --version
install: install:
- go get -u github.com/yunify/snips
- go get -u github.com/golang/lint/golint; - go get -u github.com/golang/lint/golint;
- glide install - glide install

View file

@ -1,6 +1,12 @@
# Change Log # Change Log
All notable changes to QingStor SDK for Go will be documented in this file. All notable changes to QingStor SDK for Go will be documented in this file.
## [v2.2.6] - 2017-07-21
### Fixed
- Fix concurrency issue in object related operations.
## [v2.2.5] - 2017-05-22 ## [v2.2.5] - 2017-05-22
### Fixed ### Fixed
@ -94,6 +100,7 @@ All notable changes to QingStor SDK for Go will be documented in this file.
- QingStor SDK for the Go programming language. - QingStor SDK for the Go programming language.
[v2.2.6]: https://github.com/yunify/qingstor-sdk-go/compare/v2.2.5...v2.2.6
[v2.2.5]: https://github.com/yunify/qingstor-sdk-go/compare/v2.2.4...v2.2.5 [v2.2.5]: https://github.com/yunify/qingstor-sdk-go/compare/v2.2.4...v2.2.5
[v2.2.4]: https://github.com/yunify/qingstor-sdk-go/compare/v2.2.3...v2.2.4 [v2.2.4]: https://github.com/yunify/qingstor-sdk-go/compare/v2.2.3...v2.2.4
[v2.2.3]: https://github.com/yunify/qingstor-sdk-go/compare/v2.2.2...v2.2.3 [v2.2.3]: https://github.com/yunify/qingstor-sdk-go/compare/v2.2.2...v2.2.3

View file

@ -1,6 +1,11 @@
hash: 2e6b1ed4a2ee0638abc2e819ac3c247eaf80fa0f2053cfc41eecf883054c6032 hash: 2e6b1ed4a2ee0638abc2e819ac3c247eaf80fa0f2053cfc41eecf883054c6032
updated: 2017-05-22T14:58:58.927797848+08:00 updated: 2017-07-20T20:14:05.143145325+08:00
imports: imports:
- name: github.com/DATA-DOG/godog
version: 70f777599da0f5de682b8848d356611c1738b695
subpackages:
- colors
- gherkin
- name: github.com/pengsrc/go-shared - name: github.com/pengsrc/go-shared
version: 454950d6a0782c34427d4f29b46c6bf447256f20 version: 454950d6a0782c34427d4f29b46c6bf447256f20
subpackages: subpackages:
@ -8,8 +13,8 @@ imports:
- convert - convert
- json - json
- yaml - yaml
- name: github.com/Sirupsen/logrus - name: github.com/sirupsen/logrus
version: d26492970760ca5d33129d2d799e34be5c4782eb version: 00386b3fbd637582f90cb17482dc3087646c0ac2
- name: golang.org/x/sys - name: golang.org/x/sys
version: f3918c30c5c2cb527c0b071a27c35120a6c0719a version: f3918c30c5c2cb527c0b071a27c35120a6c0719a
repo: https://github.com/golang/sys.git repo: https://github.com/golang/sys.git

View file

@ -25,7 +25,7 @@ import (
"strings" "strings"
"time" "time"
"github.com/Sirupsen/logrus" "github.com/sirupsen/logrus"
) )
var instance *logrus.Logger var instance *logrus.Logger

View file

@ -19,6 +19,7 @@ package service
import ( import (
"fmt" "fmt"
"io" "io"
"net/http"
"time" "time"
"github.com/yunify/qingstor-sdk-go/config" "github.com/yunify/qingstor-sdk-go/config"
@ -29,6 +30,7 @@ import (
var _ fmt.State var _ fmt.State
var _ io.Reader var _ io.Reader
var _ http.Header
var _ time.Time var _ time.Time
var _ config.Config var _ config.Config
@ -62,7 +64,7 @@ func (s *Bucket) Delete() (*DeleteBucketOutput, error) {
return nil, err return nil, err
} }
requestID := r.HTTPResponse.Header.Get("X-Qs-Request-Id") requestID := r.HTTPResponse.Header.Get(http.CanonicalHeaderKey("X-QS-Request-ID"))
x.RequestID = &requestID x.RequestID = &requestID
return x, err return x, err
@ -71,9 +73,11 @@ func (s *Bucket) Delete() (*DeleteBucketOutput, error) {
// DeleteRequest creates request and output object of DeleteBucket. // DeleteRequest creates request and output object of DeleteBucket.
func (s *Bucket) DeleteRequest() (*request.Request, *DeleteBucketOutput, error) { func (s *Bucket) DeleteRequest() (*request.Request, *DeleteBucketOutput, error) {
properties := *s.Properties
o := &data.Operation{ o := &data.Operation{
Config: s.Config, Config: s.Config,
Properties: s.Properties, Properties: &properties,
APIName: "DELETE Bucket", APIName: "DELETE Bucket",
RequestMethod: "DELETE", RequestMethod: "DELETE",
RequestURI: "/<bucket-name>", RequestURI: "/<bucket-name>",
@ -112,7 +116,7 @@ func (s *Bucket) DeleteCORS() (*DeleteBucketCORSOutput, error) {
return nil, err return nil, err
} }
requestID := r.HTTPResponse.Header.Get("X-Qs-Request-Id") requestID := r.HTTPResponse.Header.Get(http.CanonicalHeaderKey("X-QS-Request-ID"))
x.RequestID = &requestID x.RequestID = &requestID
return x, err return x, err
@ -121,9 +125,11 @@ func (s *Bucket) DeleteCORS() (*DeleteBucketCORSOutput, error) {
// DeleteCORSRequest creates request and output object of DeleteBucketCORS. // DeleteCORSRequest creates request and output object of DeleteBucketCORS.
func (s *Bucket) DeleteCORSRequest() (*request.Request, *DeleteBucketCORSOutput, error) { func (s *Bucket) DeleteCORSRequest() (*request.Request, *DeleteBucketCORSOutput, error) {
properties := *s.Properties
o := &data.Operation{ o := &data.Operation{
Config: s.Config, Config: s.Config,
Properties: s.Properties, Properties: &properties,
APIName: "DELETE Bucket CORS", APIName: "DELETE Bucket CORS",
RequestMethod: "DELETE", RequestMethod: "DELETE",
RequestURI: "/<bucket-name>?cors", RequestURI: "/<bucket-name>?cors",
@ -162,7 +168,7 @@ func (s *Bucket) DeleteExternalMirror() (*DeleteBucketExternalMirrorOutput, erro
return nil, err return nil, err
} }
requestID := r.HTTPResponse.Header.Get("X-Qs-Request-Id") requestID := r.HTTPResponse.Header.Get(http.CanonicalHeaderKey("X-QS-Request-ID"))
x.RequestID = &requestID x.RequestID = &requestID
return x, err return x, err
@ -171,9 +177,11 @@ func (s *Bucket) DeleteExternalMirror() (*DeleteBucketExternalMirrorOutput, erro
// DeleteExternalMirrorRequest creates request and output object of DeleteBucketExternalMirror. // DeleteExternalMirrorRequest creates request and output object of DeleteBucketExternalMirror.
func (s *Bucket) DeleteExternalMirrorRequest() (*request.Request, *DeleteBucketExternalMirrorOutput, error) { func (s *Bucket) DeleteExternalMirrorRequest() (*request.Request, *DeleteBucketExternalMirrorOutput, error) {
properties := *s.Properties
o := &data.Operation{ o := &data.Operation{
Config: s.Config, Config: s.Config,
Properties: s.Properties, Properties: &properties,
APIName: "DELETE Bucket External Mirror", APIName: "DELETE Bucket External Mirror",
RequestMethod: "DELETE", RequestMethod: "DELETE",
RequestURI: "/<bucket-name>?mirror", RequestURI: "/<bucket-name>?mirror",
@ -212,7 +220,7 @@ func (s *Bucket) DeletePolicy() (*DeleteBucketPolicyOutput, error) {
return nil, err return nil, err
} }
requestID := r.HTTPResponse.Header.Get("X-Qs-Request-Id") requestID := r.HTTPResponse.Header.Get(http.CanonicalHeaderKey("X-QS-Request-ID"))
x.RequestID = &requestID x.RequestID = &requestID
return x, err return x, err
@ -221,9 +229,11 @@ func (s *Bucket) DeletePolicy() (*DeleteBucketPolicyOutput, error) {
// DeletePolicyRequest creates request and output object of DeleteBucketPolicy. // DeletePolicyRequest creates request and output object of DeleteBucketPolicy.
func (s *Bucket) DeletePolicyRequest() (*request.Request, *DeleteBucketPolicyOutput, error) { func (s *Bucket) DeletePolicyRequest() (*request.Request, *DeleteBucketPolicyOutput, error) {
properties := *s.Properties
o := &data.Operation{ o := &data.Operation{
Config: s.Config, Config: s.Config,
Properties: s.Properties, Properties: &properties,
APIName: "DELETE Bucket Policy", APIName: "DELETE Bucket Policy",
RequestMethod: "DELETE", RequestMethod: "DELETE",
RequestURI: "/<bucket-name>?policy", RequestURI: "/<bucket-name>?policy",
@ -262,7 +272,7 @@ func (s *Bucket) DeleteMultipleObjects(input *DeleteMultipleObjectsInput) (*Dele
return nil, err return nil, err
} }
requestID := r.HTTPResponse.Header.Get("X-Qs-Request-Id") requestID := r.HTTPResponse.Header.Get(http.CanonicalHeaderKey("X-QS-Request-ID"))
x.RequestID = &requestID x.RequestID = &requestID
return x, err return x, err
@ -275,9 +285,11 @@ func (s *Bucket) DeleteMultipleObjectsRequest(input *DeleteMultipleObjectsInput)
input = &DeleteMultipleObjectsInput{} input = &DeleteMultipleObjectsInput{}
} }
properties := *s.Properties
o := &data.Operation{ o := &data.Operation{
Config: s.Config, Config: s.Config,
Properties: s.Properties, Properties: &properties,
APIName: "Delete Multiple Objects", APIName: "Delete Multiple Objects",
RequestMethod: "POST", RequestMethod: "POST",
RequestURI: "/<bucket-name>?delete", RequestURI: "/<bucket-name>?delete",
@ -351,7 +363,7 @@ func (s *Bucket) GetACL() (*GetBucketACLOutput, error) {
return nil, err return nil, err
} }
requestID := r.HTTPResponse.Header.Get("X-Qs-Request-Id") requestID := r.HTTPResponse.Header.Get(http.CanonicalHeaderKey("X-QS-Request-ID"))
x.RequestID = &requestID x.RequestID = &requestID
return x, err return x, err
@ -360,9 +372,11 @@ func (s *Bucket) GetACL() (*GetBucketACLOutput, error) {
// GetACLRequest creates request and output object of GetBucketACL. // GetACLRequest creates request and output object of GetBucketACL.
func (s *Bucket) GetACLRequest() (*request.Request, *GetBucketACLOutput, error) { func (s *Bucket) GetACLRequest() (*request.Request, *GetBucketACLOutput, error) {
properties := *s.Properties
o := &data.Operation{ o := &data.Operation{
Config: s.Config, Config: s.Config,
Properties: s.Properties, Properties: &properties,
APIName: "GET Bucket ACL", APIName: "GET Bucket ACL",
RequestMethod: "GET", RequestMethod: "GET",
RequestURI: "/<bucket-name>?acl", RequestURI: "/<bucket-name>?acl",
@ -406,7 +420,7 @@ func (s *Bucket) GetCORS() (*GetBucketCORSOutput, error) {
return nil, err return nil, err
} }
requestID := r.HTTPResponse.Header.Get("X-Qs-Request-Id") requestID := r.HTTPResponse.Header.Get(http.CanonicalHeaderKey("X-QS-Request-ID"))
x.RequestID = &requestID x.RequestID = &requestID
return x, err return x, err
@ -415,9 +429,11 @@ func (s *Bucket) GetCORS() (*GetBucketCORSOutput, error) {
// GetCORSRequest creates request and output object of GetBucketCORS. // GetCORSRequest creates request and output object of GetBucketCORS.
func (s *Bucket) GetCORSRequest() (*request.Request, *GetBucketCORSOutput, error) { func (s *Bucket) GetCORSRequest() (*request.Request, *GetBucketCORSOutput, error) {
properties := *s.Properties
o := &data.Operation{ o := &data.Operation{
Config: s.Config, Config: s.Config,
Properties: s.Properties, Properties: &properties,
APIName: "GET Bucket CORS", APIName: "GET Bucket CORS",
RequestMethod: "GET", RequestMethod: "GET",
RequestURI: "/<bucket-name>?cors", RequestURI: "/<bucket-name>?cors",
@ -459,7 +475,7 @@ func (s *Bucket) GetExternalMirror() (*GetBucketExternalMirrorOutput, error) {
return nil, err return nil, err
} }
requestID := r.HTTPResponse.Header.Get("X-Qs-Request-Id") requestID := r.HTTPResponse.Header.Get(http.CanonicalHeaderKey("X-QS-Request-ID"))
x.RequestID = &requestID x.RequestID = &requestID
return x, err return x, err
@ -468,9 +484,11 @@ func (s *Bucket) GetExternalMirror() (*GetBucketExternalMirrorOutput, error) {
// GetExternalMirrorRequest creates request and output object of GetBucketExternalMirror. // GetExternalMirrorRequest creates request and output object of GetBucketExternalMirror.
func (s *Bucket) GetExternalMirrorRequest() (*request.Request, *GetBucketExternalMirrorOutput, error) { func (s *Bucket) GetExternalMirrorRequest() (*request.Request, *GetBucketExternalMirrorOutput, error) {
properties := *s.Properties
o := &data.Operation{ o := &data.Operation{
Config: s.Config, Config: s.Config,
Properties: s.Properties, Properties: &properties,
APIName: "GET Bucket External Mirror", APIName: "GET Bucket External Mirror",
RequestMethod: "GET", RequestMethod: "GET",
RequestURI: "/<bucket-name>?mirror", RequestURI: "/<bucket-name>?mirror",
@ -512,7 +530,7 @@ func (s *Bucket) GetPolicy() (*GetBucketPolicyOutput, error) {
return nil, err return nil, err
} }
requestID := r.HTTPResponse.Header.Get("X-Qs-Request-Id") requestID := r.HTTPResponse.Header.Get(http.CanonicalHeaderKey("X-QS-Request-ID"))
x.RequestID = &requestID x.RequestID = &requestID
return x, err return x, err
@ -521,9 +539,11 @@ func (s *Bucket) GetPolicy() (*GetBucketPolicyOutput, error) {
// GetPolicyRequest creates request and output object of GetBucketPolicy. // GetPolicyRequest creates request and output object of GetBucketPolicy.
func (s *Bucket) GetPolicyRequest() (*request.Request, *GetBucketPolicyOutput, error) { func (s *Bucket) GetPolicyRequest() (*request.Request, *GetBucketPolicyOutput, error) {
properties := *s.Properties
o := &data.Operation{ o := &data.Operation{
Config: s.Config, Config: s.Config,
Properties: s.Properties, Properties: &properties,
APIName: "GET Bucket Policy", APIName: "GET Bucket Policy",
RequestMethod: "GET", RequestMethod: "GET",
RequestURI: "/<bucket-name>?policy", RequestURI: "/<bucket-name>?policy",
@ -565,7 +585,7 @@ func (s *Bucket) GetStatistics() (*GetBucketStatisticsOutput, error) {
return nil, err return nil, err
} }
requestID := r.HTTPResponse.Header.Get("X-Qs-Request-Id") requestID := r.HTTPResponse.Header.Get(http.CanonicalHeaderKey("X-QS-Request-ID"))
x.RequestID = &requestID x.RequestID = &requestID
return x, err return x, err
@ -574,9 +594,11 @@ func (s *Bucket) GetStatistics() (*GetBucketStatisticsOutput, error) {
// GetStatisticsRequest creates request and output object of GetBucketStatistics. // GetStatisticsRequest creates request and output object of GetBucketStatistics.
func (s *Bucket) GetStatisticsRequest() (*request.Request, *GetBucketStatisticsOutput, error) { func (s *Bucket) GetStatisticsRequest() (*request.Request, *GetBucketStatisticsOutput, error) {
properties := *s.Properties
o := &data.Operation{ o := &data.Operation{
Config: s.Config, Config: s.Config,
Properties: s.Properties, Properties: &properties,
APIName: "GET Bucket Statistics", APIName: "GET Bucket Statistics",
RequestMethod: "GET", RequestMethod: "GET",
RequestURI: "/<bucket-name>?stats", RequestURI: "/<bucket-name>?stats",
@ -631,7 +653,7 @@ func (s *Bucket) Head() (*HeadBucketOutput, error) {
return nil, err return nil, err
} }
requestID := r.HTTPResponse.Header.Get("X-Qs-Request-Id") requestID := r.HTTPResponse.Header.Get(http.CanonicalHeaderKey("X-QS-Request-ID"))
x.RequestID = &requestID x.RequestID = &requestID
return x, err return x, err
@ -640,9 +662,11 @@ func (s *Bucket) Head() (*HeadBucketOutput, error) {
// HeadRequest creates request and output object of HeadBucket. // HeadRequest creates request and output object of HeadBucket.
func (s *Bucket) HeadRequest() (*request.Request, *HeadBucketOutput, error) { func (s *Bucket) HeadRequest() (*request.Request, *HeadBucketOutput, error) {
properties := *s.Properties
o := &data.Operation{ o := &data.Operation{
Config: s.Config, Config: s.Config,
Properties: s.Properties, Properties: &properties,
APIName: "HEAD Bucket", APIName: "HEAD Bucket",
RequestMethod: "HEAD", RequestMethod: "HEAD",
RequestURI: "/<bucket-name>", RequestURI: "/<bucket-name>",
@ -681,7 +705,7 @@ func (s *Bucket) ListMultipartUploads(input *ListMultipartUploadsInput) (*ListMu
return nil, err return nil, err
} }
requestID := r.HTTPResponse.Header.Get("X-Qs-Request-Id") requestID := r.HTTPResponse.Header.Get(http.CanonicalHeaderKey("X-QS-Request-ID"))
x.RequestID = &requestID x.RequestID = &requestID
return x, err return x, err
@ -694,9 +718,11 @@ func (s *Bucket) ListMultipartUploadsRequest(input *ListMultipartUploadsInput) (
input = &ListMultipartUploadsInput{} input = &ListMultipartUploadsInput{}
} }
properties := *s.Properties
o := &data.Operation{ o := &data.Operation{
Config: s.Config, Config: s.Config,
Properties: s.Properties, Properties: &properties,
APIName: "List Multipart Uploads", APIName: "List Multipart Uploads",
RequestMethod: "GET", RequestMethod: "GET",
RequestURI: "/<bucket-name>?uploads", RequestURI: "/<bucket-name>?uploads",
@ -770,7 +796,7 @@ func (s *Bucket) ListObjects(input *ListObjectsInput) (*ListObjectsOutput, error
return nil, err return nil, err
} }
requestID := r.HTTPResponse.Header.Get("X-Qs-Request-Id") requestID := r.HTTPResponse.Header.Get(http.CanonicalHeaderKey("X-QS-Request-ID"))
x.RequestID = &requestID x.RequestID = &requestID
return x, err return x, err
@ -783,9 +809,11 @@ func (s *Bucket) ListObjectsRequest(input *ListObjectsInput) (*request.Request,
input = &ListObjectsInput{} input = &ListObjectsInput{}
} }
properties := *s.Properties
o := &data.Operation{ o := &data.Operation{
Config: s.Config, Config: s.Config,
Properties: s.Properties, Properties: &properties,
APIName: "GET Bucket (List Objects)", APIName: "GET Bucket (List Objects)",
RequestMethod: "GET", RequestMethod: "GET",
RequestURI: "/<bucket-name>", RequestURI: "/<bucket-name>",
@ -861,7 +889,7 @@ func (s *Bucket) Put() (*PutBucketOutput, error) {
return nil, err return nil, err
} }
requestID := r.HTTPResponse.Header.Get("X-Qs-Request-Id") requestID := r.HTTPResponse.Header.Get(http.CanonicalHeaderKey("X-QS-Request-ID"))
x.RequestID = &requestID x.RequestID = &requestID
return x, err return x, err
@ -870,9 +898,11 @@ func (s *Bucket) Put() (*PutBucketOutput, error) {
// PutRequest creates request and output object of PutBucket. // PutRequest creates request and output object of PutBucket.
func (s *Bucket) PutRequest() (*request.Request, *PutBucketOutput, error) { func (s *Bucket) PutRequest() (*request.Request, *PutBucketOutput, error) {
properties := *s.Properties
o := &data.Operation{ o := &data.Operation{
Config: s.Config, Config: s.Config,
Properties: s.Properties, Properties: &properties,
APIName: "PUT Bucket", APIName: "PUT Bucket",
RequestMethod: "PUT", RequestMethod: "PUT",
RequestURI: "/<bucket-name>", RequestURI: "/<bucket-name>",
@ -911,7 +941,7 @@ func (s *Bucket) PutACL(input *PutBucketACLInput) (*PutBucketACLOutput, error) {
return nil, err return nil, err
} }
requestID := r.HTTPResponse.Header.Get("X-Qs-Request-Id") requestID := r.HTTPResponse.Header.Get(http.CanonicalHeaderKey("X-QS-Request-ID"))
x.RequestID = &requestID x.RequestID = &requestID
return x, err return x, err
@ -924,9 +954,11 @@ func (s *Bucket) PutACLRequest(input *PutBucketACLInput) (*request.Request, *Put
input = &PutBucketACLInput{} input = &PutBucketACLInput{}
} }
properties := *s.Properties
o := &data.Operation{ o := &data.Operation{
Config: s.Config, Config: s.Config,
Properties: s.Properties, Properties: &properties,
APIName: "PUT Bucket ACL", APIName: "PUT Bucket ACL",
RequestMethod: "PUT", RequestMethod: "PUT",
RequestURI: "/<bucket-name>?acl", RequestURI: "/<bucket-name>?acl",
@ -993,7 +1025,7 @@ func (s *Bucket) PutCORS(input *PutBucketCORSInput) (*PutBucketCORSOutput, error
return nil, err return nil, err
} }
requestID := r.HTTPResponse.Header.Get("X-Qs-Request-Id") requestID := r.HTTPResponse.Header.Get(http.CanonicalHeaderKey("X-QS-Request-ID"))
x.RequestID = &requestID x.RequestID = &requestID
return x, err return x, err
@ -1006,9 +1038,11 @@ func (s *Bucket) PutCORSRequest(input *PutBucketCORSInput) (*request.Request, *P
input = &PutBucketCORSInput{} input = &PutBucketCORSInput{}
} }
properties := *s.Properties
o := &data.Operation{ o := &data.Operation{
Config: s.Config, Config: s.Config,
Properties: s.Properties, Properties: &properties,
APIName: "PUT Bucket CORS", APIName: "PUT Bucket CORS",
RequestMethod: "PUT", RequestMethod: "PUT",
RequestURI: "/<bucket-name>?cors", RequestURI: "/<bucket-name>?cors",
@ -1075,7 +1109,7 @@ func (s *Bucket) PutExternalMirror(input *PutBucketExternalMirrorInput) (*PutBuc
return nil, err return nil, err
} }
requestID := r.HTTPResponse.Header.Get("X-Qs-Request-Id") requestID := r.HTTPResponse.Header.Get(http.CanonicalHeaderKey("X-QS-Request-ID"))
x.RequestID = &requestID x.RequestID = &requestID
return x, err return x, err
@ -1088,9 +1122,11 @@ func (s *Bucket) PutExternalMirrorRequest(input *PutBucketExternalMirrorInput) (
input = &PutBucketExternalMirrorInput{} input = &PutBucketExternalMirrorInput{}
} }
properties := *s.Properties
o := &data.Operation{ o := &data.Operation{
Config: s.Config, Config: s.Config,
Properties: s.Properties, Properties: &properties,
APIName: "PUT Bucket External Mirror", APIName: "PUT Bucket External Mirror",
RequestMethod: "PUT", RequestMethod: "PUT",
RequestURI: "/<bucket-name>?mirror", RequestURI: "/<bucket-name>?mirror",
@ -1149,7 +1185,7 @@ func (s *Bucket) PutPolicy(input *PutBucketPolicyInput) (*PutBucketPolicyOutput,
return nil, err return nil, err
} }
requestID := r.HTTPResponse.Header.Get("X-Qs-Request-Id") requestID := r.HTTPResponse.Header.Get(http.CanonicalHeaderKey("X-QS-Request-ID"))
x.RequestID = &requestID x.RequestID = &requestID
return x, err return x, err
@ -1162,9 +1198,11 @@ func (s *Bucket) PutPolicyRequest(input *PutBucketPolicyInput) (*request.Request
input = &PutBucketPolicyInput{} input = &PutBucketPolicyInput{}
} }
properties := *s.Properties
o := &data.Operation{ o := &data.Operation{
Config: s.Config, Config: s.Config,
Properties: s.Properties, Properties: &properties,
APIName: "PUT Bucket Policy", APIName: "PUT Bucket Policy",
RequestMethod: "PUT", RequestMethod: "PUT",
RequestURI: "/<bucket-name>?policy", RequestURI: "/<bucket-name>?policy",

View file

@ -19,6 +19,7 @@ package service
import ( import (
"fmt" "fmt"
"io" "io"
"net/http"
"time" "time"
"github.com/yunify/qingstor-sdk-go/config" "github.com/yunify/qingstor-sdk-go/config"
@ -29,6 +30,7 @@ import (
var _ fmt.State var _ fmt.State
var _ io.Reader var _ io.Reader
var _ http.Header
var _ time.Time var _ time.Time
var _ config.Config var _ config.Config
@ -46,7 +48,7 @@ func (s *Bucket) AbortMultipartUpload(objectKey string, input *AbortMultipartUpl
return nil, err return nil, err
} }
requestID := r.HTTPResponse.Header.Get("X-Qs-Request-Id") requestID := r.HTTPResponse.Header.Get(http.CanonicalHeaderKey("X-QS-Request-ID"))
x.RequestID = &requestID x.RequestID = &requestID
return x, err return x, err
@ -59,9 +61,13 @@ func (s *Bucket) AbortMultipartUploadRequest(objectKey string, input *AbortMulti
input = &AbortMultipartUploadInput{} input = &AbortMultipartUploadInput{}
} }
properties := *s.Properties
properties.ObjectKey = &objectKey
o := &data.Operation{ o := &data.Operation{
Config: s.Config, Config: s.Config,
Properties: s.Properties, Properties: &properties,
APIName: "Abort Multipart Upload", APIName: "Abort Multipart Upload",
RequestMethod: "DELETE", RequestMethod: "DELETE",
RequestURI: "/<bucket-name>/<object-key>", RequestURI: "/<bucket-name>/<object-key>",
@ -70,8 +76,6 @@ func (s *Bucket) AbortMultipartUploadRequest(objectKey string, input *AbortMulti
}, },
} }
s.Properties.ObjectKey = &objectKey
x := &AbortMultipartUploadOutput{} x := &AbortMultipartUploadOutput{}
r, err := request.New(o, input, x) r, err := request.New(o, input, x)
if err != nil { if err != nil {
@ -122,7 +126,7 @@ func (s *Bucket) CompleteMultipartUpload(objectKey string, input *CompleteMultip
return nil, err return nil, err
} }
requestID := r.HTTPResponse.Header.Get("X-Qs-Request-Id") requestID := r.HTTPResponse.Header.Get(http.CanonicalHeaderKey("X-QS-Request-ID"))
x.RequestID = &requestID x.RequestID = &requestID
return x, err return x, err
@ -135,9 +139,13 @@ func (s *Bucket) CompleteMultipartUploadRequest(objectKey string, input *Complet
input = &CompleteMultipartUploadInput{} input = &CompleteMultipartUploadInput{}
} }
properties := *s.Properties
properties.ObjectKey = &objectKey
o := &data.Operation{ o := &data.Operation{
Config: s.Config, Config: s.Config,
Properties: s.Properties, Properties: &properties,
APIName: "Complete multipart upload", APIName: "Complete multipart upload",
RequestMethod: "POST", RequestMethod: "POST",
RequestURI: "/<bucket-name>/<object-key>", RequestURI: "/<bucket-name>/<object-key>",
@ -146,8 +154,6 @@ func (s *Bucket) CompleteMultipartUploadRequest(objectKey string, input *Complet
}, },
} }
s.Properties.ObjectKey = &objectKey
x := &CompleteMultipartUploadOutput{} x := &CompleteMultipartUploadOutput{}
r, err := request.New(o, input, x) r, err := request.New(o, input, x)
if err != nil { if err != nil {
@ -217,7 +223,7 @@ func (s *Bucket) DeleteObject(objectKey string) (*DeleteObjectOutput, error) {
return nil, err return nil, err
} }
requestID := r.HTTPResponse.Header.Get("X-Qs-Request-Id") requestID := r.HTTPResponse.Header.Get(http.CanonicalHeaderKey("X-QS-Request-ID"))
x.RequestID = &requestID x.RequestID = &requestID
return x, err return x, err
@ -226,9 +232,13 @@ func (s *Bucket) DeleteObject(objectKey string) (*DeleteObjectOutput, error) {
// DeleteObjectRequest creates request and output object of DeleteObject. // DeleteObjectRequest creates request and output object of DeleteObject.
func (s *Bucket) DeleteObjectRequest(objectKey string) (*request.Request, *DeleteObjectOutput, error) { func (s *Bucket) DeleteObjectRequest(objectKey string) (*request.Request, *DeleteObjectOutput, error) {
properties := *s.Properties
properties.ObjectKey = &objectKey
o := &data.Operation{ o := &data.Operation{
Config: s.Config, Config: s.Config,
Properties: s.Properties, Properties: &properties,
APIName: "DELETE Object", APIName: "DELETE Object",
RequestMethod: "DELETE", RequestMethod: "DELETE",
RequestURI: "/<bucket-name>/<object-key>", RequestURI: "/<bucket-name>/<object-key>",
@ -237,8 +247,6 @@ func (s *Bucket) DeleteObjectRequest(objectKey string) (*request.Request, *Delet
}, },
} }
s.Properties.ObjectKey = &objectKey
x := &DeleteObjectOutput{} x := &DeleteObjectOutput{}
r, err := request.New(o, nil, x) r, err := request.New(o, nil, x)
if err != nil { if err != nil {
@ -269,7 +277,7 @@ func (s *Bucket) GetObject(objectKey string, input *GetObjectInput) (*GetObjectO
return nil, err return nil, err
} }
requestID := r.HTTPResponse.Header.Get("X-Qs-Request-Id") requestID := r.HTTPResponse.Header.Get(http.CanonicalHeaderKey("X-QS-Request-ID"))
x.RequestID = &requestID x.RequestID = &requestID
return x, err return x, err
@ -282,9 +290,13 @@ func (s *Bucket) GetObjectRequest(objectKey string, input *GetObjectInput) (*req
input = &GetObjectInput{} input = &GetObjectInput{}
} }
properties := *s.Properties
properties.ObjectKey = &objectKey
o := &data.Operation{ o := &data.Operation{
Config: s.Config, Config: s.Config,
Properties: s.Properties, Properties: &properties,
APIName: "GET Object", APIName: "GET Object",
RequestMethod: "GET", RequestMethod: "GET",
RequestURI: "/<bucket-name>/<object-key>", RequestURI: "/<bucket-name>/<object-key>",
@ -296,8 +308,6 @@ func (s *Bucket) GetObjectRequest(objectKey string, input *GetObjectInput) (*req
}, },
} }
s.Properties.ObjectKey = &objectKey
x := &GetObjectOutput{} x := &GetObjectOutput{}
r, err := request.New(o, input, x) r, err := request.New(o, input, x)
if err != nil { if err != nil {
@ -379,7 +389,7 @@ func (s *Bucket) HeadObject(objectKey string, input *HeadObjectInput) (*HeadObje
return nil, err return nil, err
} }
requestID := r.HTTPResponse.Header.Get("X-Qs-Request-Id") requestID := r.HTTPResponse.Header.Get(http.CanonicalHeaderKey("X-QS-Request-ID"))
x.RequestID = &requestID x.RequestID = &requestID
return x, err return x, err
@ -392,9 +402,13 @@ func (s *Bucket) HeadObjectRequest(objectKey string, input *HeadObjectInput) (*r
input = &HeadObjectInput{} input = &HeadObjectInput{}
} }
properties := *s.Properties
properties.ObjectKey = &objectKey
o := &data.Operation{ o := &data.Operation{
Config: s.Config, Config: s.Config,
Properties: s.Properties, Properties: &properties,
APIName: "HEAD Object", APIName: "HEAD Object",
RequestMethod: "HEAD", RequestMethod: "HEAD",
RequestURI: "/<bucket-name>/<object-key>", RequestURI: "/<bucket-name>/<object-key>",
@ -403,8 +417,6 @@ func (s *Bucket) HeadObjectRequest(objectKey string, input *HeadObjectInput) (*r
}, },
} }
s.Properties.ObjectKey = &objectKey
x := &HeadObjectOutput{} x := &HeadObjectOutput{}
r, err := request.New(o, input, x) r, err := request.New(o, input, x)
if err != nil { if err != nil {
@ -469,7 +481,7 @@ func (s *Bucket) InitiateMultipartUpload(objectKey string, input *InitiateMultip
return nil, err return nil, err
} }
requestID := r.HTTPResponse.Header.Get("X-Qs-Request-Id") requestID := r.HTTPResponse.Header.Get(http.CanonicalHeaderKey("X-QS-Request-ID"))
x.RequestID = &requestID x.RequestID = &requestID
return x, err return x, err
@ -482,9 +494,13 @@ func (s *Bucket) InitiateMultipartUploadRequest(objectKey string, input *Initiat
input = &InitiateMultipartUploadInput{} input = &InitiateMultipartUploadInput{}
} }
properties := *s.Properties
properties.ObjectKey = &objectKey
o := &data.Operation{ o := &data.Operation{
Config: s.Config, Config: s.Config,
Properties: s.Properties, Properties: &properties,
APIName: "Initiate Multipart Upload", APIName: "Initiate Multipart Upload",
RequestMethod: "POST", RequestMethod: "POST",
RequestURI: "/<bucket-name>/<object-key>?uploads", RequestURI: "/<bucket-name>/<object-key>?uploads",
@ -493,8 +509,6 @@ func (s *Bucket) InitiateMultipartUploadRequest(objectKey string, input *Initiat
}, },
} }
s.Properties.ObjectKey = &objectKey
x := &InitiateMultipartUploadOutput{} x := &InitiateMultipartUploadOutput{}
r, err := request.New(o, input, x) r, err := request.New(o, input, x)
if err != nil { if err != nil {
@ -553,7 +567,7 @@ func (s *Bucket) ListMultipart(objectKey string, input *ListMultipartInput) (*Li
return nil, err return nil, err
} }
requestID := r.HTTPResponse.Header.Get("X-Qs-Request-Id") requestID := r.HTTPResponse.Header.Get(http.CanonicalHeaderKey("X-QS-Request-ID"))
x.RequestID = &requestID x.RequestID = &requestID
return x, err return x, err
@ -566,9 +580,13 @@ func (s *Bucket) ListMultipartRequest(objectKey string, input *ListMultipartInpu
input = &ListMultipartInput{} input = &ListMultipartInput{}
} }
properties := *s.Properties
properties.ObjectKey = &objectKey
o := &data.Operation{ o := &data.Operation{
Config: s.Config, Config: s.Config,
Properties: s.Properties, Properties: &properties,
APIName: "List Multipart", APIName: "List Multipart",
RequestMethod: "GET", RequestMethod: "GET",
RequestURI: "/<bucket-name>/<object-key>", RequestURI: "/<bucket-name>/<object-key>",
@ -577,8 +595,6 @@ func (s *Bucket) ListMultipartRequest(objectKey string, input *ListMultipartInpu
}, },
} }
s.Properties.ObjectKey = &objectKey
x := &ListMultipartOutput{} x := &ListMultipartOutput{}
r, err := request.New(o, input, x) r, err := request.New(o, input, x)
if err != nil { if err != nil {
@ -638,7 +654,7 @@ func (s *Bucket) OptionsObject(objectKey string, input *OptionsObjectInput) (*Op
return nil, err return nil, err
} }
requestID := r.HTTPResponse.Header.Get("X-Qs-Request-Id") requestID := r.HTTPResponse.Header.Get(http.CanonicalHeaderKey("X-QS-Request-ID"))
x.RequestID = &requestID x.RequestID = &requestID
return x, err return x, err
@ -651,9 +667,13 @@ func (s *Bucket) OptionsObjectRequest(objectKey string, input *OptionsObjectInpu
input = &OptionsObjectInput{} input = &OptionsObjectInput{}
} }
properties := *s.Properties
properties.ObjectKey = &objectKey
o := &data.Operation{ o := &data.Operation{
Config: s.Config, Config: s.Config,
Properties: s.Properties, Properties: &properties,
APIName: "OPTIONS Object", APIName: "OPTIONS Object",
RequestMethod: "OPTIONS", RequestMethod: "OPTIONS",
RequestURI: "/<bucket-name>/<object-key>", RequestURI: "/<bucket-name>/<object-key>",
@ -662,8 +682,6 @@ func (s *Bucket) OptionsObjectRequest(objectKey string, input *OptionsObjectInpu
}, },
} }
s.Properties.ObjectKey = &objectKey
x := &OptionsObjectOutput{} x := &OptionsObjectOutput{}
r, err := request.New(o, input, x) r, err := request.New(o, input, x)
if err != nil { if err != nil {
@ -736,7 +754,7 @@ func (s *Bucket) PutObject(objectKey string, input *PutObjectInput) (*PutObjectO
return nil, err return nil, err
} }
requestID := r.HTTPResponse.Header.Get("X-Qs-Request-Id") requestID := r.HTTPResponse.Header.Get(http.CanonicalHeaderKey("X-QS-Request-ID"))
x.RequestID = &requestID x.RequestID = &requestID
return x, err return x, err
@ -749,9 +767,13 @@ func (s *Bucket) PutObjectRequest(objectKey string, input *PutObjectInput) (*req
input = &PutObjectInput{} input = &PutObjectInput{}
} }
properties := *s.Properties
properties.ObjectKey = &objectKey
o := &data.Operation{ o := &data.Operation{
Config: s.Config, Config: s.Config,
Properties: s.Properties, Properties: &properties,
APIName: "PUT Object", APIName: "PUT Object",
RequestMethod: "PUT", RequestMethod: "PUT",
RequestURI: "/<bucket-name>/<object-key>", RequestURI: "/<bucket-name>/<object-key>",
@ -760,8 +782,6 @@ func (s *Bucket) PutObjectRequest(objectKey string, input *PutObjectInput) (*req
}, },
} }
s.Properties.ObjectKey = &objectKey
x := &PutObjectOutput{} x := &PutObjectOutput{}
r, err := request.New(o, input, x) r, err := request.New(o, input, x)
if err != nil { if err != nil {
@ -841,7 +861,7 @@ func (s *Bucket) UploadMultipart(objectKey string, input *UploadMultipartInput)
return nil, err return nil, err
} }
requestID := r.HTTPResponse.Header.Get("X-Qs-Request-Id") requestID := r.HTTPResponse.Header.Get(http.CanonicalHeaderKey("X-QS-Request-ID"))
x.RequestID = &requestID x.RequestID = &requestID
return x, err return x, err
@ -854,9 +874,13 @@ func (s *Bucket) UploadMultipartRequest(objectKey string, input *UploadMultipart
input = &UploadMultipartInput{} input = &UploadMultipartInput{}
} }
properties := *s.Properties
properties.ObjectKey = &objectKey
o := &data.Operation{ o := &data.Operation{
Config: s.Config, Config: s.Config,
Properties: s.Properties, Properties: &properties,
APIName: "Upload Multipart", APIName: "Upload Multipart",
RequestMethod: "PUT", RequestMethod: "PUT",
RequestURI: "/<bucket-name>/<object-key>", RequestURI: "/<bucket-name>/<object-key>",
@ -865,8 +889,6 @@ func (s *Bucket) UploadMultipartRequest(objectKey string, input *UploadMultipart
}, },
} }
s.Properties.ObjectKey = &objectKey
x := &UploadMultipartOutput{} x := &UploadMultipartOutput{}
r, err := request.New(o, input, x) r, err := request.New(o, input, x)
if err != nil { if err != nil {

View file

@ -18,11 +18,15 @@
package service package service
import ( import (
"net/http"
"github.com/yunify/qingstor-sdk-go/config" "github.com/yunify/qingstor-sdk-go/config"
"github.com/yunify/qingstor-sdk-go/request" "github.com/yunify/qingstor-sdk-go/request"
"github.com/yunify/qingstor-sdk-go/request/data" "github.com/yunify/qingstor-sdk-go/request/data"
) )
var _ http.Header
// Service QingStor provides low-cost and reliable online storage service with unlimited storage space, high read and write performance, high reliability and data safety, fine-grained access control, and easy to use API. // Service QingStor provides low-cost and reliable online storage service with unlimited storage space, high read and write performance, high reliability and data safety, fine-grained access control, and easy to use API.
type Service struct { type Service struct {
Config *config.Config Config *config.Config
@ -47,7 +51,7 @@ func (s *Service) ListBuckets(input *ListBucketsInput) (*ListBucketsOutput, erro
return nil, err return nil, err
} }
requestID := r.HTTPResponse.Header.Get("X-Qs-Request-Id") requestID := r.HTTPResponse.Header.Get(http.CanonicalHeaderKey("X-QS-Request-ID"))
x.RequestID = &requestID x.RequestID = &requestID
return x, err return x, err

View file

@ -20,11 +20,15 @@
package service package service
import ( import (
"net/http"
"github.com/yunify/qingstor-sdk-go/config" "github.com/yunify/qingstor-sdk-go/config"
"github.com/yunify/qingstor-sdk-go/request" "github.com/yunify/qingstor-sdk-go/request"
"github.com/yunify/qingstor-sdk-go/request/data" "github.com/yunify/qingstor-sdk-go/request/data"
) )
var _ http.Header
{{if $service.Description}}// Service {{$service.Description}}{{end}} {{if $service.Description}}// Service {{$service.Description}}{{end}}
type Service struct { type Service struct {
Config *config.Config Config *config.Config

View file

@ -153,7 +153,7 @@
return nil, err return nil, err
} }
requestID := r.HTTPResponse.Header.Get("X-Qs-Request-Id") requestID := r.HTTPResponse.Header.Get(http.CanonicalHeaderKey("X-QS-Request-ID"))
x.RequestID = &requestID x.RequestID = &requestID
return x, err return x, err
@ -186,10 +186,17 @@
{{$uri := replace $uri "}" ">" -1}} {{$uri := replace $uri "}" ">" -1}}
{{$uri := dashConnected $uri}} {{$uri := dashConnected $uri}}
{{- if ne $belongs "Service"}}
properties := *s.Properties
{{- end}}
{{if eq $service.Name "Object"}}
properties.ObjectKey = &objectKey
{{end}}
o := &data.Operation{ o := &data.Operation{
Config: s.Config, Config: s.Config,
{{- if ne $belongs "Service"}} {{- if ne $belongs "Service"}}
Properties: s.Properties, Properties: &properties,
{{- end}} {{- end}}
APIName: "{{$operation.Name}}", APIName: "{{$operation.Name}}",
RequestMethod: "{{$operation.Request.Method}}", RequestMethod: "{{$operation.Request.Method}}",
@ -210,10 +217,6 @@
{{end -}} {{end -}}
} }
{{if eq $service.Name "Object"}}
s.Properties.ObjectKey = &objectKey
{{end}}
x := &{{$opID}}Output{} x := &{{$opID}}Output{}
r, err := request.New(o, {{if $hasInput}}input{{else}}nil{{end}}, x) r, err := request.New(o, {{if $hasInput}}input{{else}}nil{{end}}, x)
if err != nil { if err != nil {

View file

@ -22,6 +22,7 @@ package service
import ( import (
"fmt" "fmt"
"io" "io"
"net/http"
"time" "time"
"github.com/yunify/qingstor-sdk-go/config" "github.com/yunify/qingstor-sdk-go/config"
@ -32,6 +33,7 @@ import (
var _ fmt.State var _ fmt.State
var _ io.Reader var _ io.Reader
var _ http.Header
var _ time.Time var _ time.Time
var _ config.Config var _ config.Config

View file

@ -25,6 +25,7 @@ import (
"net/http" "net/http"
"os" "os"
"os/exec" "os/exec"
"sync"
"github.com/DATA-DOG/godog" "github.com/DATA-DOG/godog"
@ -66,7 +67,9 @@ func ObjectFeatureContext(s *godog.Suite) {
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
var putObjectOutput *qs.PutObjectOutput const concurrency = 16
var putObjectOutputs [concurrency]*qs.PutObjectOutput
func putObjectWithKey(objectKey string) error { func putObjectWithKey(objectKey string) error {
_, err = exec.Command("dd", "if=/dev/zero", "of=/tmp/sdk_bin", "bs=1024", "count=1").Output() _, err = exec.Command("dd", "if=/dev/zero", "of=/tmp/sdk_bin", "bs=1024", "count=1").Output()
@ -75,189 +78,557 @@ func putObjectWithKey(objectKey string) error {
} }
defer os.Remove("/tmp/sdk_bin") defer os.Remove("/tmp/sdk_bin")
file, err := os.Open("/tmp/sdk_bin") errChan := make(chan error, concurrency)
if err != nil {
return err wg := sync.WaitGroup{}
wg.Add(concurrency)
for i := 0; i < concurrency; i++ {
go func(index int, errChan chan<- error) {
wg.Done()
file, err := os.Open("/tmp/sdk_bin")
if err != nil {
errChan <- err
return
}
defer file.Close()
hash := md5.New()
_, err = io.Copy(hash, file)
if err != nil {
errChan <- err
return
}
hashInBytes := hash.Sum(nil)[:16]
md5String := hex.EncodeToString(hashInBytes)
//file.Seek(0, io.SeekStart)
file.Seek(0, 0)
if len(objectKey) > 1000 {
objectKey = objectKey[:1000]
}
putObjectOutput, err := bucket.PutObject(
fmt.Sprintf("%s-%d", objectKey, index),
&qs.PutObjectInput{
ContentType: qs.String("text/plain"),
ContentMD5: qs.String(md5String),
Body: file,
},
)
if err != nil {
errChan <- err
return
}
putObjectOutputs[index] = putObjectOutput
errChan <- nil
return
}(i, errChan)
} }
defer file.Close() wg.Wait()
hash := md5.New() for i := 0; i < concurrency; i++ {
_, err = io.Copy(hash, file) err = <-errChan
hashInBytes := hash.Sum(nil)[:16] if err != nil {
md5String := hex.EncodeToString(hashInBytes) return err
}
//file.Seek(0, io.SeekStart) }
file.Seek(0, 0) return nil
putObjectOutput, err = bucket.PutObject(objectKey, &qs.PutObjectInput{
ContentType: qs.String("text/plain"),
ContentMD5: qs.String(md5String),
Body: file,
})
return err
} }
func putObjectStatusCodeIs(statusCode int) error { func putObjectStatusCodeIs(statusCode int) error {
return checkEqual(qs.IntValue(putObjectOutput.StatusCode), statusCode) for _, output := range putObjectOutputs {
err = checkEqual(qs.IntValue(output.StatusCode), statusCode)
if err != nil {
return err
}
}
return nil
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
var copyObjectOutput *qs.PutObjectOutput var copyObjectOutputs [concurrency]*qs.PutObjectOutput
func copyObjectWithKey(objectKey string) error { func copyObjectWithKey(objectKey string) error {
copyObjectKey := fmt.Sprintf(`%s_copy`, objectKey) errChan := make(chan error, concurrency)
copyObjectOutput, err = bucket.PutObject(copyObjectKey, &qs.PutObjectInput{
XQSCopySource: qs.String(fmt.Sprintf(`/%s/%s`, tc.BucketName, objectKey)), wg := sync.WaitGroup{}
}) wg.Add(concurrency)
return err for i := 0; i < concurrency; i++ {
go func(index int, errChan chan<- error) {
wg.Done()
if len(objectKey) > 1000 {
objectKey = objectKey[:1000]
}
copyObjectOutput, err := bucket.PutObject(
fmt.Sprintf("%s-%d-copy", objectKey, index),
&qs.PutObjectInput{
XQSCopySource: qs.String(
fmt.Sprintf("/%s/%s-%d", tc.BucketName, objectKey, index),
),
})
if err != nil {
errChan <- err
return
}
copyObjectOutputs[index] = copyObjectOutput
errChan <- nil
return
}(i, errChan)
}
wg.Wait()
for i := 0; i < concurrency; i++ {
err = <-errChan
if err != nil {
return err
}
}
return nil
} }
func copyObjectStatusCodeIs(statusCode int) error { func copyObjectStatusCodeIs(statusCode int) error {
return checkEqual(qs.IntValue(copyObjectOutput.StatusCode), statusCode) for _, output := range copyObjectOutputs {
err = checkEqual(qs.IntValue(output.StatusCode), statusCode)
if err != nil {
return err
}
}
return nil
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
var moveObjectOutput *qs.PutObjectOutput var moveObjectOutputs [concurrency]*qs.PutObjectOutput
func moveObjectWithKey(objectKey string) error { func moveObjectWithKey(objectKey string) error {
copyObjectKey := fmt.Sprintf(`%s_copy`, objectKey) errChan := make(chan error, concurrency)
moveObjectKey := fmt.Sprintf(`%s_move`, objectKey)
moveObjectOutput, err = bucket.PutObject(moveObjectKey, &qs.PutObjectInput{ wg := sync.WaitGroup{}
XQSMoveSource: qs.String(fmt.Sprintf(`/%s/%s`, tc.BucketName, copyObjectKey)), wg.Add(concurrency)
}) for i := 0; i < concurrency; i++ {
return err go func(index int, errChan chan<- error) {
wg.Done()
if len(objectKey) > 1000 {
objectKey = objectKey[:1000]
}
moveObjectOutput, err := bucket.PutObject(
fmt.Sprintf("%s-%d-move", objectKey, index),
&qs.PutObjectInput{
XQSMoveSource: qs.String(
fmt.Sprintf(`/%s/%s-%d-copy`, tc.BucketName, objectKey, index),
),
})
if err != nil {
errChan <- err
return
}
moveObjectOutputs[index] = moveObjectOutput
errChan <- nil
return
}(i, errChan)
}
wg.Wait()
for i := 0; i < concurrency; i++ {
err = <-errChan
if err != nil {
return err
}
}
return nil
} }
func moveObjectStatusCodeIs(statusCode int) error { func moveObjectStatusCodeIs(statusCode int) error {
return checkEqual(qs.IntValue(moveObjectOutput.StatusCode), statusCode) for _, output := range moveObjectOutputs {
err = checkEqual(qs.IntValue(output.StatusCode), statusCode)
if err != nil {
return err
}
}
return nil
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
var getObjectOutput *qs.GetObjectOutput var getObjectOutputs [concurrency]*qs.GetObjectOutput
func getObjectWithKey(objectKey string) error { func getObjectWithKey(objectKey string) error {
getObjectOutput, err = bucket.GetObject(objectKey, nil) errChan := make(chan error, concurrency)
return err
wg := sync.WaitGroup{}
wg.Add(concurrency)
for i := 0; i < concurrency; i++ {
go func(index int, errChan chan<- error) {
wg.Done()
if len(objectKey) > 1000 {
objectKey = objectKey[:1000]
}
getObjectOutput, err := bucket.GetObject(
fmt.Sprintf("%s-%d", objectKey, index), nil,
)
if err != nil {
errChan <- err
return
}
getObjectOutputs[index] = getObjectOutput
errChan <- nil
return
}(i, errChan)
}
wg.Wait()
for i := 0; i < concurrency; i++ {
err = <-errChan
if err != nil {
return err
}
}
return nil
} }
func getObjectStatusCodeIs(statusCode int) error { func getObjectStatusCodeIs(statusCode int) error {
return checkEqual(qs.IntValue(getObjectOutput.StatusCode), statusCode) for _, output := range getObjectOutputs {
err = checkEqual(qs.IntValue(output.StatusCode), statusCode)
if err != nil {
return err
}
}
return nil
} }
func getObjectContentLengthIs(length int) error { func getObjectContentLengthIs(length int) error {
buffer := &bytes.Buffer{} buffer := &bytes.Buffer{}
buffer.ReadFrom(getObjectOutput.Body) for _, output := range getObjectOutputs {
getObjectOutput.Body.Close() buffer.Truncate(0)
return checkEqual(len(buffer.Bytes())*1024, length) buffer.ReadFrom(output.Body)
err = checkEqual(len(buffer.Bytes())*1024, length)
if err != nil {
return err
}
}
return nil
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
var getObjectWithContentTypeRequest *request.Request var getObjectWithContentTypeRequests [concurrency]*request.Request
func getObjectWithContentType(objectKey, contentType string) error { func getObjectWithContentType(objectKey, contentType string) error {
getObjectWithContentTypeRequest, _, err = bucket.GetObjectRequest( errChan := make(chan error, concurrency)
objectKey,
&qs.GetObjectInput{ wg := sync.WaitGroup{}
ResponseContentType: qs.String(contentType), wg.Add(concurrency)
}, for i := 0; i < concurrency; i++ {
) go func(index int, errChan chan<- error) {
if err != nil { wg.Done()
return err
if len(objectKey) > 1000 {
objectKey = objectKey[:1000]
}
getObjectWithContentTypeRequest, _, err := bucket.GetObjectRequest(
fmt.Sprintf("%s-%d", objectKey, index),
&qs.GetObjectInput{
ResponseContentType: qs.String(contentType),
},
)
if err != nil {
errChan <- err
return
}
err = getObjectWithContentTypeRequest.Send()
if err != nil {
errChan <- err
return
}
err = getObjectWithContentTypeRequest.Send()
if err != nil {
errChan <- err
return
}
getObjectWithContentTypeRequests[index] = getObjectWithContentTypeRequest
errChan <- nil
return
}(i, errChan)
} }
err = getObjectWithContentTypeRequest.Send() wg.Wait()
if err != nil {
return err for i := 0; i < concurrency; i++ {
err = <-errChan
if err != nil {
return err
}
} }
return nil return nil
} }
func getObjectContentTypeIs(contentType string) error { func getObjectContentTypeIs(contentType string) error {
return checkEqual(getObjectWithContentTypeRequest.HTTPResponse.Header.Get("Content-Type"), contentType) for _, r := range getObjectWithContentTypeRequests {
err = checkEqual(r.HTTPResponse.Header.Get("Content-Type"), contentType)
if err != nil {
return err
}
}
return nil
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
var getObjectWithQuerySignatureURL string var getObjectWithQuerySignatureURLs [concurrency]string
func getObjectWithQuerySignature(objectKey string) error { func getObjectWithQuerySignature(objectKey string) error {
r, _, err := bucket.GetObjectRequest(objectKey, nil) errChan := make(chan error, concurrency)
if err != nil {
return err
}
err = r.SignQuery(10) wg := sync.WaitGroup{}
if err != nil { wg.Add(concurrency)
return err for i := 0; i < concurrency; i++ {
} go func(index int, errChan chan<- error) {
wg.Done()
getObjectWithQuerySignatureURL = r.HTTPRequest.URL.String() if len(objectKey) > 1000 {
objectKey = objectKey[:1000]
}
r, _, err := bucket.GetObjectRequest(
fmt.Sprintf("%s-%d", objectKey, index), nil,
)
if err != nil {
errChan <- err
return
}
err = r.SignQuery(10)
if err != nil {
errChan <- err
return
}
getObjectWithQuerySignatureURLs[index] = r.HTTPRequest.URL.String()
errChan <- nil
return
}(i, errChan)
}
wg.Wait()
for i := 0; i < concurrency; i++ {
err = <-errChan
if err != nil {
return err
}
}
return nil return nil
} }
func getObjectWithQuerySignatureContentLengthIs(length int) error { func getObjectWithQuerySignatureContentLengthIs(length int) error {
out, err := http.Get(getObjectWithQuerySignatureURL)
if err != nil {
return err
}
buffer := &bytes.Buffer{} buffer := &bytes.Buffer{}
buffer.ReadFrom(out.Body) for _, url := range getObjectWithQuerySignatureURLs {
out.Body.Close() out, err := http.Get(url)
if err != nil {
return checkEqual(len(buffer.Bytes())*1024, length) return err
}
buffer.Truncate(0)
buffer.ReadFrom(out.Body)
out.Body.Close()
err = checkEqual(len(buffer.Bytes())*1024, length)
if err != nil {
return err
}
}
return nil
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
var headObjectOutput *qs.HeadObjectOutput var headObjectOutputs [concurrency]*qs.HeadObjectOutput
func headObjectWithKey(objectKey string) error { func headObjectWithKey(objectKey string) error {
headObjectOutput, err = bucket.HeadObject(objectKey, nil) errChan := make(chan error, concurrency)
return err
wg := sync.WaitGroup{}
wg.Add(concurrency)
for i := 0; i < concurrency; i++ {
go func(index int, errChan chan<- error) {
wg.Done()
if len(objectKey) > 1000 {
objectKey = objectKey[:1000]
}
headObjectOutput, err := bucket.HeadObject(
fmt.Sprintf("%s-%d", objectKey, index), nil,
)
if err != nil {
errChan <- err
return
}
headObjectOutputs[index] = headObjectOutput
errChan <- nil
return
}(i, errChan)
}
wg.Wait()
for i := 0; i < concurrency; i++ {
err = <-errChan
if err != nil {
return err
}
}
return nil
} }
func headObjectStatusCodeIs(statusCode int) error { func headObjectStatusCodeIs(statusCode int) error {
return checkEqual(qs.IntValue(headObjectOutput.StatusCode), statusCode) for _, output := range headObjectOutputs {
err = checkEqual(qs.IntValue(output.StatusCode), statusCode)
if err != nil {
return err
}
}
return nil
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
var optionsObjectOutput *qs.OptionsObjectOutput var optionsObjectOutputs [concurrency]*qs.OptionsObjectOutput
func optionsObjectWithMethodAndOrigin(objectKey, method, origin string) error { func optionsObjectWithMethodAndOrigin(objectKey, method, origin string) error {
optionsObjectOutput, err = bucket.OptionsObject( errChan := make(chan error, concurrency)
objectKey,
&qs.OptionsObjectInput{ wg := sync.WaitGroup{}
AccessControlRequestMethod: qs.String(method), wg.Add(concurrency)
Origin: qs.String(origin), for i := 0; i < concurrency; i++ {
}, go func(index int, errChan chan<- error) {
) wg.Done()
return err
if len(objectKey) > 1000 {
objectKey = objectKey[:1000]
}
optionsObjectOutput, err := bucket.OptionsObject(
fmt.Sprintf("%s-%d", objectKey, index),
&qs.OptionsObjectInput{
AccessControlRequestMethod: qs.String(method),
Origin: qs.String(origin),
},
)
if err != nil {
errChan <- err
return
}
optionsObjectOutputs[index] = optionsObjectOutput
errChan <- nil
return
}(i, errChan)
}
wg.Wait()
for i := 0; i < concurrency; i++ {
err = <-errChan
if err != nil {
return err
}
}
return nil
} }
func optionsObjectStatusCodeIs(statusCode int) error { func optionsObjectStatusCodeIs(statusCode int) error {
return checkEqual(qs.IntValue(optionsObjectOutput.StatusCode), statusCode) for _, output := range optionsObjectOutputs {
err = checkEqual(qs.IntValue(output.StatusCode), statusCode)
if err != nil {
return err
}
}
return nil
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
var deleteObjectOutput *qs.DeleteObjectOutput var deleteObjectOutputs [concurrency]*qs.DeleteObjectOutput
var deleteTheMoveObjectOutput *qs.DeleteObjectOutput var deleteTheMoveObjectOutputs [concurrency]*qs.DeleteObjectOutput
func deleteObjectWithKey(objectKey string) error { func deleteObjectWithKey(objectKey string) error {
deleteObjectOutput, err = bucket.DeleteObject(objectKey) errChan := make(chan error, concurrency)
return err
wg := sync.WaitGroup{}
wg.Add(concurrency)
for i := 0; i < concurrency; i++ {
go func(index int, errChan chan<- error) {
wg.Done()
if len(objectKey) > 1000 {
objectKey = objectKey[:1000]
}
deleteObjectOutput, err := bucket.DeleteObject(
fmt.Sprintf("%s-%d", objectKey, index),
)
if err != nil {
errChan <- err
return
}
deleteObjectOutputs[index] = deleteObjectOutput
errChan <- nil
return
}(i, errChan)
}
wg.Wait()
for i := 0; i < concurrency; i++ {
err = <-errChan
if err != nil {
return err
}
}
return nil
} }
func deleteObjectStatusCodeIs(statusCode int) error { func deleteObjectStatusCodeIs(statusCode int) error {
return checkEqual(qs.IntValue(deleteObjectOutput.StatusCode), statusCode) for _, output := range deleteObjectOutputs {
err = checkEqual(qs.IntValue(output.StatusCode), statusCode)
if err != nil {
return err
}
}
return nil
} }
func deleteTheMoveObjectWithKey(objectKey string) error { func deleteTheMoveObjectWithKey(objectKey string) error {
deleteTheMoveObjectOutput, err = bucket.DeleteObject(fmt.Sprintf(`%s_move`, objectKey)) errChan := make(chan error, concurrency)
return err
wg := sync.WaitGroup{}
wg.Add(concurrency)
for i := 0; i < concurrency; i++ {
go func(index int, errChan chan<- error) {
wg.Done()
if len(objectKey) > 1000 {
objectKey = objectKey[:1000]
}
deleteTheMoveObjectOutput, err := bucket.DeleteObject(
fmt.Sprintf("%s-%d-move", objectKey, index),
)
if err != nil {
errChan <- err
return
}
deleteTheMoveObjectOutputs[index] = deleteTheMoveObjectOutput
errChan <- nil
return
}(i, errChan)
}
wg.Wait()
for i := 0; i < concurrency; i++ {
err = <-errChan
if err != nil {
return err
}
}
return nil
} }
func deleteTheMoveObjectStatusCodeIs(statusCode int) error { func deleteTheMoveObjectStatusCodeIs(statusCode int) error {
return checkEqual(qs.IntValue(deleteTheMoveObjectOutput.StatusCode), statusCode) for _, output := range deleteTheMoveObjectOutputs {
err = checkEqual(qs.IntValue(output.StatusCode), statusCode)
if err != nil {
return err
}
}
return nil
} }

View file

@ -20,4 +20,4 @@
package sdk package sdk
// Version number. // Version number.
const Version = "2.2.5" const Version = "2.2.6"