-
Notifications
You must be signed in to change notification settings - Fork 541
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update minio-go #2299
Update minio-go #2299
Conversation
harshavardhana
commented
Nov 2, 2017
- Avoid setting server encryption headers with x-amz-meta (Update to new changes in minio-go #859)
- Remove redirectHeaders method (Add atomic package for atomic file writes, use that in quick config #857)
- Honor file pointer set in PutObject method (Avoid possible corrupted data when saving with quick #856)
- Fix docs and add a validator tool for our api docs (User struct{} instead of bool for saving session, saves a 1byte #850)
- requestMetadata should take the md5 and sha256 with expected encodings. (Prettify the progress bar output #852)
- Added a new method SetUserMetadata to the PostPolicy (Rename isMcConfigExist to isMcConfigExists for brevity #839)
- Do not need to strictly validate request params in Presign API. (Fix simple typo in session command help #832)
- Avoid setting server encryption headers with x-amz-meta (minio#859) - Remove redirectHeaders method (minio#857) - Honor file pointer set in PutObject method (minio#856) - Fix docs and add a validator tool for our api docs (minio#850) - requestMetadata should take the md5 and sha256 with expected encodings. (minio#852) - Added a new method SetUserMetadata to the PostPolicy (minio#839) - Do not need to strictly validate request params in Presign API. (minio#832)
Codecov Report
@@ Coverage Diff @@
## master #2299 +/- ##
======================================
Coverage 10.7% 10.7%
======================================
Files 102 102
Lines 9916 9916
======================================
Hits 1062 1062
Misses 8716 8716
Partials 138 138 Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Verified basic commands manually. LGTM
@@ -40,6 +34,26 @@ func isObject(reader io.Reader) (ok bool) { | |||
// Verify if reader is a generic ReaderAt | |||
func isReadAt(reader io.Reader) (ok bool) { | |||
_, ok = reader.(io.ReaderAt) | |||
if ok { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if ok {
=> if _, ok = reader.(io.ReaderAt); ok {
if ok { | ||
var v *os.File | ||
v, ok = reader.(*os.File) | ||
if ok { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if ok {
=> if v, ok = reader.(*os.File); ok {
// and such a functionality is used in the subsequent code path. | ||
if isFile(reader) || !isObject(reader) && isReadAt(reader) { | ||
if !isObject(reader) && isReadAt(reader) { | ||
// Verify if the reader implements ReadAt and it is not a *minio.Object then we will use parallel uploader. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we need to have the comment come before the command, like:
// Verify if the reader implements ReadAt and it is not a *minio.Object then we will use parallel uploader.
if !isObject(reader) && isReadAt(reader) {
"/dev/stdin", | ||
"/dev/stdout", | ||
"/dev/stderr", | ||
} { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO, this looks much better, and more readable:
for _, f := range []string{"/dev/stdin",
"/dev/stdout",
"/dev/stderr"}
{
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This formatting is automatic by gofmt and this PR has nothing to do with these chnages, so won't be making these changes.
@@ -237,8 +223,7 @@ func privateNew(endpoint string, creds *credentials.Credentials, secure bool, re | |||
|
|||
// Instantiate http client and bucket location cache. | |||
clnt.httpClient = &http.Client{ | |||
Transport: defaultMinioTransport, | |||
CheckRedirect: redirectHeaders, | |||
Transport: defaultMinioTransport, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can combine all in one line:
clnt.httpClient = &http.Client{Transport: defaultMinioTransport}
@@ -74,8 +62,7 @@ func NewIAM(endpoint string) *Credentials { | |||
} | |||
p := &IAM{ | |||
Client: &http.Client{ | |||
Transport: http.DefaultTransport, | |||
CheckRedirect: redirectHeaders, | |||
Transport: http.DefaultTransport, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Combine them all in 2 lines:
p := &IAM { Client: &http.Client{Transport: http.DefaultTransport},
endpoint: endpoint }
@@ -253,17 +251,27 @@ func writeCanonicalizedHeaders(buf *bytes.Buffer, req http.Request) { | |||
} | |||
} | |||
|
|||
// The following list is already sorted and should always be, otherwise we could | |||
// have signature-related issues | |||
// AWS S3 Signature V2 calculation rule is give here: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo in comment:
// AWS S3 Signature V2 calculation rule is give here:
=???=> given
// SetUserMetadata - Set user metadata as a key/value couple. | ||
// Can be retrieved through a HEAD request or an event. | ||
func (p *PostPolicy) SetUserMetadata(key string, value string) error { | ||
if strings.TrimSpace(key) == "" || key == "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
strings.TrimSpace(key)
for key=""
returns ""
.
So, the 2nd condition is covered in the 1st part.
Then we can simplify the if condition as:
if strings.TrimSpace(key) == "" {
@@ -38,18 +40,18 @@ func xmlDecoder(body io.Reader, v interface{}) error { | |||
return d.Decode(v) | |||
} | |||
|
|||
// sum256 calculate sha256 sum for an input byte array. | |||
func sum256(data []byte) []byte { | |||
// sum256 calculate sha256sum for an input byte array, returns hex encoded. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// sum256 calculate sha256sum ... => // sum256Hex calculates sha256sum ...`
I cannot make your changes in this PR @ebozduman you should open them separately in minio-go this is Just a vendorized changes from minio-go master. |