forked from mirrors/gotosocial
[chore]: Bump github.com/minio/minio-go/v7 from 7.0.52 to 7.0.53 (#1808)
Bumps [github.com/minio/minio-go/v7](https://github.com/minio/minio-go) from 7.0.52 to 7.0.53. - [Release notes](https://github.com/minio/minio-go/releases) - [Commits](https://github.com/minio/minio-go/compare/v7.0.52...v7.0.53) --- updated-dependencies: - dependency-name: github.com/minio/minio-go/v7 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This commit is contained in:
parent
c48abd8bc0
commit
a0952adc40
10 changed files with 378 additions and 22 deletions
2
go.mod
2
go.mod
|
@ -35,7 +35,7 @@ require (
|
||||||
github.com/jackc/pgx/v5 v5.3.1
|
github.com/jackc/pgx/v5 v5.3.1
|
||||||
github.com/microcosm-cc/bluemonday v1.0.23
|
github.com/microcosm-cc/bluemonday v1.0.23
|
||||||
github.com/miekg/dns v1.1.54
|
github.com/miekg/dns v1.1.54
|
||||||
github.com/minio/minio-go/v7 v7.0.52
|
github.com/minio/minio-go/v7 v7.0.53
|
||||||
github.com/mitchellh/mapstructure v1.5.0
|
github.com/mitchellh/mapstructure v1.5.0
|
||||||
github.com/oklog/ulid v1.3.1
|
github.com/oklog/ulid v1.3.1
|
||||||
github.com/spf13/cobra v1.7.0
|
github.com/spf13/cobra v1.7.0
|
||||||
|
|
4
go.sum
4
go.sum
|
@ -452,8 +452,8 @@ github.com/miekg/dns v1.1.54 h1:5jon9mWcb0sFJGpnI99tOMhCPyJ+RPVz5b63MQG0VWI=
|
||||||
github.com/miekg/dns v1.1.54/go.mod h1:uInx36IzPl7FYnDcMeVWxj9byh7DutNykX4G9Sj60FY=
|
github.com/miekg/dns v1.1.54/go.mod h1:uInx36IzPl7FYnDcMeVWxj9byh7DutNykX4G9Sj60FY=
|
||||||
github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34=
|
github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34=
|
||||||
github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM=
|
github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM=
|
||||||
github.com/minio/minio-go/v7 v7.0.52 h1:8XhG36F6oKQUDDSuz6dY3rioMzovKjW40W6ANuN0Dps=
|
github.com/minio/minio-go/v7 v7.0.53 h1:qtPyQ+b0Cc1ums3LsnVMAYULPNdAGz8qdX8R2zl9XMU=
|
||||||
github.com/minio/minio-go/v7 v7.0.52/go.mod h1:IbbodHyjUAguneyucUaahv+VMNs/EOTV9du7A7/Z3HU=
|
github.com/minio/minio-go/v7 v7.0.53/go.mod h1:IbbodHyjUAguneyucUaahv+VMNs/EOTV9du7A7/Z3HU=
|
||||||
github.com/minio/sha256-simd v1.0.0 h1:v1ta+49hkWZyvaKwrQB8elexRqm6Y0aMLjCNsrYxo6g=
|
github.com/minio/sha256-simd v1.0.0 h1:v1ta+49hkWZyvaKwrQB8elexRqm6Y0aMLjCNsrYxo6g=
|
||||||
github.com/minio/sha256-simd v1.0.0/go.mod h1:OuYzVNI5vcoYIAmbIvHPl3N3jUzVedXbKy5RFepssQM=
|
github.com/minio/sha256-simd v1.0.0/go.mod h1:OuYzVNI5vcoYIAmbIvHPl3N3jUzVedXbKy5RFepssQM=
|
||||||
github.com/mitchellh/hashstructure/v2 v2.0.2 h1:vGKWl0YJqUNxE8d+h8f6NJLcCJrgbhC4NcD46KavDd4=
|
github.com/mitchellh/hashstructure/v2 v2.0.2 h1:vGKWl0YJqUNxE8d+h8f6NJLcCJrgbhC4NcD46KavDd4=
|
||||||
|
|
7
vendor/github.com/minio/minio-go/v7/api-bucket-notification.go
generated
vendored
7
vendor/github.com/minio/minio-go/v7/api-bucket-notification.go
generated
vendored
|
@ -166,6 +166,7 @@ func (c *Client) ListenBucketNotification(ctx context.Context, bucketName, prefi
|
||||||
|
|
||||||
// Prepare urlValues to pass into the request on every loop
|
// Prepare urlValues to pass into the request on every loop
|
||||||
urlValues := make(url.Values)
|
urlValues := make(url.Values)
|
||||||
|
urlValues.Set("ping", "10")
|
||||||
urlValues.Set("prefix", prefix)
|
urlValues.Set("prefix", prefix)
|
||||||
urlValues.Set("suffix", suffix)
|
urlValues.Set("suffix", suffix)
|
||||||
urlValues["events"] = events
|
urlValues["events"] = events
|
||||||
|
@ -224,6 +225,12 @@ func (c *Client) ListenBucketNotification(ctx context.Context, bucketName, prefi
|
||||||
closeResponse(resp)
|
closeResponse(resp)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Empty events pinged from the server
|
||||||
|
if len(notificationInfo.Records) == 0 && notificationInfo.Err == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
// Send notificationInfo
|
// Send notificationInfo
|
||||||
select {
|
select {
|
||||||
case notificationInfoCh <- notificationInfo:
|
case notificationInfoCh <- notificationInfo:
|
||||||
|
|
149
vendor/github.com/minio/minio-go/v7/api-put-object-fan-out.go
generated
vendored
Normal file
149
vendor/github.com/minio/minio-go/v7/api-put-object-fan-out.go
generated
vendored
Normal file
|
@ -0,0 +1,149 @@
|
||||||
|
/*
|
||||||
|
* MinIO Go Library for Amazon S3 Compatible Cloud Storage
|
||||||
|
* Copyright 2023 MinIO, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package minio
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
|
"io"
|
||||||
|
"mime/multipart"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// PutObjectFanOutRequest this is the request structure sent
|
||||||
|
// to the server to fan-out the stream to multiple objects.
|
||||||
|
type PutObjectFanOutRequest struct {
|
||||||
|
Key string `json:"key"`
|
||||||
|
UserMetadata map[string]string `json:"metadata,omitempty"`
|
||||||
|
UserTags map[string]string `json:"tags,omitempty"`
|
||||||
|
ContentType string `json:"contentType,omitempty"`
|
||||||
|
ContentEncoding string `json:"contentEncoding,omitempty"`
|
||||||
|
ContentDisposition string `json:"contentDisposition,omitempty"`
|
||||||
|
ContentLanguage string `json:"contentLanguage,omitempty"`
|
||||||
|
CacheControl string `json:"cacheControl,omitempty"`
|
||||||
|
Retention RetentionMode `json:"retention,omitempty"`
|
||||||
|
RetainUntilDate *time.Time `json:"retainUntil,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// PutObjectFanOutResponse this is the response structure sent
|
||||||
|
// by the server upon success or failure for each object
|
||||||
|
// fan-out keys. Additionally this response carries ETag,
|
||||||
|
// VersionID and LastModified for each object fan-out.
|
||||||
|
type PutObjectFanOutResponse struct {
|
||||||
|
Key string `json:"key"`
|
||||||
|
ETag string `json:"etag,omitempty"`
|
||||||
|
VersionID string `json:"versionId,omitempty"`
|
||||||
|
LastModified *time.Time `json:"lastModified,omitempty"`
|
||||||
|
Error error `json:"error,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// PutObjectFanOut - is a variant of PutObject instead of writing a single object from a single
|
||||||
|
// stream multiple objects are written, defined via a list of PutObjectFanOutRequests. Each entry
|
||||||
|
// in PutObjectFanOutRequest carries an object keyname and its relevant metadata if any. `Key` is
|
||||||
|
// mandatory, rest of the other options in PutObjectFanOutRequest are optional.
|
||||||
|
func (c *Client) PutObjectFanOut(ctx context.Context, bucket string, body io.Reader, fanOutReq ...PutObjectFanOutRequest) ([]PutObjectFanOutResponse, error) {
|
||||||
|
if len(fanOutReq) == 0 {
|
||||||
|
return nil, errInvalidArgument("fan out requests cannot be empty")
|
||||||
|
}
|
||||||
|
|
||||||
|
policy := NewPostPolicy()
|
||||||
|
policy.SetBucket(bucket)
|
||||||
|
policy.SetKey(strconv.FormatInt(time.Now().UnixNano(), 16))
|
||||||
|
|
||||||
|
// Expires in 15 minutes.
|
||||||
|
policy.SetExpires(time.Now().UTC().Add(15 * time.Minute))
|
||||||
|
|
||||||
|
url, formData, err := c.PresignedPostPolicy(ctx, policy)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
r, w := io.Pipe()
|
||||||
|
|
||||||
|
req, err := http.NewRequest(http.MethodPost, url.String(), r)
|
||||||
|
if err != nil {
|
||||||
|
w.Close()
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var b strings.Builder
|
||||||
|
enc := json.NewEncoder(&b)
|
||||||
|
for _, req := range fanOutReq {
|
||||||
|
if req.Key == "" {
|
||||||
|
w.Close()
|
||||||
|
return nil, errors.New("PutObjectFanOutRequest.Key is mandatory and cannot be empty")
|
||||||
|
}
|
||||||
|
if err = enc.Encode(&req); err != nil {
|
||||||
|
w.Close()
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mwriter := multipart.NewWriter(w)
|
||||||
|
req.Header.Add("Content-Type", mwriter.FormDataContentType())
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
defer w.Close()
|
||||||
|
defer mwriter.Close()
|
||||||
|
|
||||||
|
for k, v := range formData {
|
||||||
|
if err := mwriter.WriteField(k, v); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := mwriter.WriteField("x-minio-fanout-list", b.String()); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
mw, err := mwriter.CreateFormFile("file", "fanout-content")
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err = io.Copy(mw, body); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
resp, err := c.do(req)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
defer closeResponse(resp)
|
||||||
|
|
||||||
|
if resp.StatusCode != http.StatusOK {
|
||||||
|
return nil, httpRespToErrorResponse(resp, bucket, "fanout-content")
|
||||||
|
}
|
||||||
|
|
||||||
|
dec := json.NewDecoder(resp.Body)
|
||||||
|
fanOutResp := make([]PutObjectFanOutResponse, 0, len(fanOutReq))
|
||||||
|
for dec.More() {
|
||||||
|
var m PutObjectFanOutResponse
|
||||||
|
if err = dec.Decode(&m); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
fanOutResp = append(fanOutResp, m)
|
||||||
|
}
|
||||||
|
|
||||||
|
return fanOutResp, nil
|
||||||
|
}
|
10
vendor/github.com/minio/minio-go/v7/api-stat.go
generated
vendored
10
vendor/github.com/minio/minio-go/v7/api-stat.go
generated
vendored
|
@ -20,7 +20,6 @@ package minio
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
|
|
||||||
"github.com/minio/minio-go/v7/pkg/s3utils"
|
"github.com/minio/minio-go/v7/pkg/s3utils"
|
||||||
)
|
)
|
||||||
|
@ -57,7 +56,8 @@ func (c *Client) BucketExists(ctx context.Context, bucketName string) (bool, err
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// StatObject verifies if object exists and you have permission to access.
|
// StatObject verifies if object exists, you have permission to access it
|
||||||
|
// and returns information about the object.
|
||||||
func (c *Client) StatObject(ctx context.Context, bucketName, objectName string, opts StatObjectOptions) (ObjectInfo, error) {
|
func (c *Client) StatObject(ctx context.Context, bucketName, objectName string, opts StatObjectOptions) (ObjectInfo, error) {
|
||||||
// Input validation.
|
// Input validation.
|
||||||
if err := s3utils.CheckValidBucketName(bucketName); err != nil {
|
if err := s3utils.CheckValidBucketName(bucketName); err != nil {
|
||||||
|
@ -74,15 +74,11 @@ func (c *Client) StatObject(ctx context.Context, bucketName, objectName string,
|
||||||
headers.Set(isMinioTgtReplicationReady, "true")
|
headers.Set(isMinioTgtReplicationReady, "true")
|
||||||
}
|
}
|
||||||
|
|
||||||
urlValues := make(url.Values)
|
|
||||||
if opts.VersionID != "" {
|
|
||||||
urlValues.Set("versionId", opts.VersionID)
|
|
||||||
}
|
|
||||||
// Execute HEAD on objectName.
|
// Execute HEAD on objectName.
|
||||||
resp, err := c.executeMethod(ctx, http.MethodHead, requestMetadata{
|
resp, err := c.executeMethod(ctx, http.MethodHead, requestMetadata{
|
||||||
bucketName: bucketName,
|
bucketName: bucketName,
|
||||||
objectName: objectName,
|
objectName: objectName,
|
||||||
queryValues: urlValues,
|
queryValues: opts.toQueryValues(),
|
||||||
contentSHA256Hex: emptySHA256Hex,
|
contentSHA256Hex: emptySHA256Hex,
|
||||||
customHeader: headers,
|
customHeader: headers,
|
||||||
})
|
})
|
||||||
|
|
2
vendor/github.com/minio/minio-go/v7/api.go
generated
vendored
2
vendor/github.com/minio/minio-go/v7/api.go
generated
vendored
|
@ -124,7 +124,7 @@ type Options struct {
|
||||||
// Global constants.
|
// Global constants.
|
||||||
const (
|
const (
|
||||||
libraryName = "minio-go"
|
libraryName = "minio-go"
|
||||||
libraryVersion = "v7.0.52"
|
libraryVersion = "v7.0.53"
|
||||||
)
|
)
|
||||||
|
|
||||||
// User Agent should always following the below style.
|
// User Agent should always following the below style.
|
||||||
|
|
4
vendor/github.com/minio/minio-go/v7/bucket-cache.go
generated
vendored
4
vendor/github.com/minio/minio-go/v7/bucket-cache.go
generated
vendored
|
@ -240,9 +240,7 @@ func (c *Client) getBucketLocationRequest(ctx context.Context, bucketName string
|
||||||
}
|
}
|
||||||
|
|
||||||
if signerType.IsV2() {
|
if signerType.IsV2() {
|
||||||
// Get Bucket Location calls should be always path style
|
req = signer.SignV2(*req, accessKeyID, secretAccessKey, isVirtualStyle)
|
||||||
isVirtualHost := false
|
|
||||||
req = signer.SignV2(*req, accessKeyID, secretAccessKey, isVirtualHost)
|
|
||||||
return req, nil
|
return req, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
212
vendor/github.com/minio/minio-go/v7/functional_tests.go
generated
vendored
212
vendor/github.com/minio/minio-go/v7/functional_tests.go
generated
vendored
|
@ -2087,7 +2087,7 @@ func testPutObjectWithChecksums() {
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, test := range tests {
|
for i, test := range tests {
|
||||||
bufSize := dataFileMap["datafile-129-MB"]
|
bufSize := dataFileMap["datafile-10-kB"]
|
||||||
|
|
||||||
// Save the data
|
// Save the data
|
||||||
objectName := randString(60, rand.NewSource(time.Now().UnixNano()), "")
|
objectName := randString(60, rand.NewSource(time.Now().UnixNano()), "")
|
||||||
|
@ -2101,7 +2101,7 @@ func testPutObjectWithChecksums() {
|
||||||
}
|
}
|
||||||
|
|
||||||
meta := map[string]string{}
|
meta := map[string]string{}
|
||||||
reader := getDataReader("datafile-129-MB")
|
reader := getDataReader("datafile-10-kB")
|
||||||
b, err := io.ReadAll(reader)
|
b, err := io.ReadAll(reader)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logError(testName, function, args, startTime, "", "Read failed", err)
|
logError(testName, function, args, startTime, "", "Read failed", err)
|
||||||
|
@ -2112,6 +2112,7 @@ func testPutObjectWithChecksums() {
|
||||||
// Wrong CRC.
|
// Wrong CRC.
|
||||||
meta[test.header] = base64.StdEncoding.EncodeToString(h.Sum(nil))
|
meta[test.header] = base64.StdEncoding.EncodeToString(h.Sum(nil))
|
||||||
args["metadata"] = meta
|
args["metadata"] = meta
|
||||||
|
args["range"] = "false"
|
||||||
|
|
||||||
resp, err := c.PutObject(context.Background(), bucketName, objectName, bytes.NewReader(b), int64(bufSize), minio.PutObjectOptions{
|
resp, err := c.PutObject(context.Background(), bucketName, objectName, bytes.NewReader(b), int64(bufSize), minio.PutObjectOptions{
|
||||||
DisableMultipart: true,
|
DisableMultipart: true,
|
||||||
|
@ -2133,6 +2134,7 @@ func testPutObjectWithChecksums() {
|
||||||
|
|
||||||
resp, err = c.PutObject(context.Background(), bucketName, objectName, bytes.NewReader(b), int64(bufSize), minio.PutObjectOptions{
|
resp, err = c.PutObject(context.Background(), bucketName, objectName, bytes.NewReader(b), int64(bufSize), minio.PutObjectOptions{
|
||||||
DisableMultipart: true,
|
DisableMultipart: true,
|
||||||
|
DisableContentSha256: true,
|
||||||
UserMetadata: meta,
|
UserMetadata: meta,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -2146,6 +2148,7 @@ func testPutObjectWithChecksums() {
|
||||||
|
|
||||||
// Read the data back
|
// Read the data back
|
||||||
gopts := minio.GetObjectOptions{Checksum: true}
|
gopts := minio.GetObjectOptions{Checksum: true}
|
||||||
|
|
||||||
r, err := c.GetObject(context.Background(), bucketName, objectName, gopts)
|
r, err := c.GetObject(context.Background(), bucketName, objectName, gopts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logError(testName, function, args, startTime, "", "GetObject failed", err)
|
logError(testName, function, args, startTime, "", "GetObject failed", err)
|
||||||
|
@ -2157,7 +2160,6 @@ func testPutObjectWithChecksums() {
|
||||||
logError(testName, function, args, startTime, "", "Stat failed", err)
|
logError(testName, function, args, startTime, "", "Stat failed", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
cmpChecksum(st.ChecksumSHA256, meta["x-amz-checksum-sha256"])
|
cmpChecksum(st.ChecksumSHA256, meta["x-amz-checksum-sha256"])
|
||||||
cmpChecksum(st.ChecksumSHA1, meta["x-amz-checksum-sha1"])
|
cmpChecksum(st.ChecksumSHA1, meta["x-amz-checksum-sha1"])
|
||||||
cmpChecksum(st.ChecksumCRC32, meta["x-amz-checksum-crc32"])
|
cmpChecksum(st.ChecksumCRC32, meta["x-amz-checksum-crc32"])
|
||||||
|
@ -2176,6 +2178,209 @@ func testPutObjectWithChecksums() {
|
||||||
logError(testName, function, args, startTime, "", "Object already closed, should respond with error", err)
|
logError(testName, function, args, startTime, "", "Object already closed, should respond with error", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
args["range"] = "true"
|
||||||
|
err = gopts.SetRange(100, 1000)
|
||||||
|
if err != nil {
|
||||||
|
logError(testName, function, args, startTime, "", "SetRange failed", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
r, err = c.GetObject(context.Background(), bucketName, objectName, gopts)
|
||||||
|
if err != nil {
|
||||||
|
logError(testName, function, args, startTime, "", "GetObject failed", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
b, err = io.ReadAll(r)
|
||||||
|
if err != nil {
|
||||||
|
logError(testName, function, args, startTime, "", "Read failed", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
st, err = r.Stat()
|
||||||
|
if err != nil {
|
||||||
|
logError(testName, function, args, startTime, "", "Stat failed", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Range requests should return empty checksums...
|
||||||
|
cmpChecksum(st.ChecksumSHA256, "")
|
||||||
|
cmpChecksum(st.ChecksumSHA1, "")
|
||||||
|
cmpChecksum(st.ChecksumCRC32, "")
|
||||||
|
cmpChecksum(st.ChecksumCRC32C, "")
|
||||||
|
|
||||||
|
delete(args, "range")
|
||||||
|
delete(args, "metadata")
|
||||||
|
}
|
||||||
|
|
||||||
|
successLogger(testName, function, args, startTime).Info()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test PutObject with custom checksums.
|
||||||
|
func testPutMultipartObjectWithChecksums() {
|
||||||
|
// initialize logging params
|
||||||
|
startTime := time.Now()
|
||||||
|
testName := getFuncName()
|
||||||
|
function := "PutObject(bucketName, objectName, reader,size, opts)"
|
||||||
|
args := map[string]interface{}{
|
||||||
|
"bucketName": "",
|
||||||
|
"objectName": "",
|
||||||
|
"opts": "minio.PutObjectOptions{UserMetadata: metadata, Progress: progress}",
|
||||||
|
}
|
||||||
|
|
||||||
|
if !isFullMode() {
|
||||||
|
ignoredLog(testName, function, args, startTime, "Skipping functional tests for short/quick runs").Info()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Seed random based on current time.
|
||||||
|
rand.Seed(time.Now().Unix())
|
||||||
|
|
||||||
|
// Instantiate new minio client object.
|
||||||
|
c, err := minio.New(os.Getenv(serverEndpoint),
|
||||||
|
&minio.Options{
|
||||||
|
Creds: credentials.NewStaticV4(os.Getenv(accessKey), os.Getenv(secretKey), ""),
|
||||||
|
Secure: mustParseBool(os.Getenv(enableHTTPS)),
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
logError(testName, function, args, startTime, "", "MinIO client object creation failed", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Enable tracing, write to stderr.
|
||||||
|
// c.TraceOn(os.Stderr)
|
||||||
|
|
||||||
|
// Set user agent.
|
||||||
|
c.SetAppInfo("MinIO-go-FunctionalTest", "0.1.0")
|
||||||
|
|
||||||
|
// Generate a new random bucket name.
|
||||||
|
bucketName := randString(60, rand.NewSource(time.Now().UnixNano()), "minio-go-test-")
|
||||||
|
args["bucketName"] = bucketName
|
||||||
|
|
||||||
|
// Make a new bucket.
|
||||||
|
err = c.MakeBucket(context.Background(), bucketName, minio.MakeBucketOptions{Region: "us-east-1"})
|
||||||
|
if err != nil {
|
||||||
|
logError(testName, function, args, startTime, "", "Make bucket failed", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
hashMultiPart := func(b []byte, partSize int, hasher hash.Hash) string {
|
||||||
|
r := bytes.NewReader(b)
|
||||||
|
tmp := make([]byte, partSize)
|
||||||
|
parts := 0
|
||||||
|
var all []byte
|
||||||
|
for {
|
||||||
|
n, err := io.ReadFull(r, tmp)
|
||||||
|
if err != nil && err != io.ErrUnexpectedEOF {
|
||||||
|
logError(testName, function, args, startTime, "", "Calc crc failed", err)
|
||||||
|
}
|
||||||
|
if n == 0 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
parts++
|
||||||
|
hasher.Reset()
|
||||||
|
hasher.Write(tmp[:n])
|
||||||
|
all = append(all, hasher.Sum(nil)...)
|
||||||
|
if err != nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
hasher.Reset()
|
||||||
|
hasher.Write(all)
|
||||||
|
return fmt.Sprintf("%s-%d", base64.StdEncoding.EncodeToString(hasher.Sum(nil)), parts)
|
||||||
|
}
|
||||||
|
defer cleanupBucket(bucketName, c)
|
||||||
|
tests := []struct {
|
||||||
|
header string
|
||||||
|
hasher hash.Hash
|
||||||
|
|
||||||
|
// Checksum values
|
||||||
|
ChecksumCRC32 string
|
||||||
|
ChecksumCRC32C string
|
||||||
|
ChecksumSHA1 string
|
||||||
|
ChecksumSHA256 string
|
||||||
|
}{
|
||||||
|
// Currently there is no way to override the checksum type.
|
||||||
|
{header: "x-amz-checksum-crc32c", hasher: crc32.New(crc32.MakeTable(crc32.Castagnoli)), ChecksumCRC32C: "OpEx0Q==-13"},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, test := range tests {
|
||||||
|
bufSize := dataFileMap["datafile-129-MB"]
|
||||||
|
|
||||||
|
// Save the data
|
||||||
|
objectName := randString(60, rand.NewSource(time.Now().UnixNano()), "")
|
||||||
|
args["objectName"] = objectName
|
||||||
|
|
||||||
|
cmpChecksum := func(got, want string) {
|
||||||
|
if want != got {
|
||||||
|
//logError(testName, function, args, startTime, "", "checksum mismatch", fmt.Errorf("want %s, got %s", want, got))
|
||||||
|
fmt.Printf("want %s, got %s\n", want, got)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const partSize = 10 << 20
|
||||||
|
reader := getDataReader("datafile-129-MB")
|
||||||
|
b, err := io.ReadAll(reader)
|
||||||
|
if err != nil {
|
||||||
|
logError(testName, function, args, startTime, "", "Read failed", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
reader.Close()
|
||||||
|
h := test.hasher
|
||||||
|
h.Reset()
|
||||||
|
test.ChecksumCRC32C = hashMultiPart(b, partSize, test.hasher)
|
||||||
|
|
||||||
|
// Set correct CRC.
|
||||||
|
|
||||||
|
resp, err := c.PutObject(context.Background(), bucketName, objectName, io.NopCloser(bytes.NewReader(b)), int64(bufSize), minio.PutObjectOptions{
|
||||||
|
DisableContentSha256: true,
|
||||||
|
DisableMultipart: false,
|
||||||
|
UserMetadata: nil,
|
||||||
|
PartSize: partSize,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
logError(testName, function, args, startTime, "", "PutObject failed", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
cmpChecksum(resp.ChecksumSHA256, test.ChecksumSHA256)
|
||||||
|
cmpChecksum(resp.ChecksumSHA1, test.ChecksumSHA1)
|
||||||
|
cmpChecksum(resp.ChecksumCRC32, test.ChecksumCRC32)
|
||||||
|
cmpChecksum(resp.ChecksumCRC32C, test.ChecksumCRC32C)
|
||||||
|
|
||||||
|
// Read the data back
|
||||||
|
gopts := minio.GetObjectOptions{Checksum: true}
|
||||||
|
gopts.PartNumber = 2
|
||||||
|
|
||||||
|
// We cannot use StatObject, since it ignores partnumber.
|
||||||
|
r, err := c.GetObject(context.Background(), bucketName, objectName, gopts)
|
||||||
|
if err != nil {
|
||||||
|
logError(testName, function, args, startTime, "", "GetObject failed", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
io.Copy(io.Discard, r)
|
||||||
|
st, err := r.Stat()
|
||||||
|
if err != nil {
|
||||||
|
logError(testName, function, args, startTime, "", "Stat failed", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test part 2 checksum...
|
||||||
|
h.Reset()
|
||||||
|
h.Write(b[partSize : 2*partSize])
|
||||||
|
got := base64.StdEncoding.EncodeToString(h.Sum(nil))
|
||||||
|
if test.ChecksumSHA256 != "" {
|
||||||
|
cmpChecksum(st.ChecksumSHA256, got)
|
||||||
|
}
|
||||||
|
if test.ChecksumSHA1 != "" {
|
||||||
|
cmpChecksum(st.ChecksumSHA1, got)
|
||||||
|
}
|
||||||
|
if test.ChecksumCRC32 != "" {
|
||||||
|
cmpChecksum(st.ChecksumCRC32, got)
|
||||||
|
}
|
||||||
|
if test.ChecksumCRC32C != "" {
|
||||||
|
cmpChecksum(st.ChecksumCRC32C, got)
|
||||||
|
}
|
||||||
|
|
||||||
delete(args, "metadata")
|
delete(args, "metadata")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12318,6 +12523,7 @@ func main() {
|
||||||
testCompose10KSourcesV2()
|
testCompose10KSourcesV2()
|
||||||
testUserMetadataCopyingV2()
|
testUserMetadataCopyingV2()
|
||||||
testPutObjectWithChecksums()
|
testPutObjectWithChecksums()
|
||||||
|
testPutMultipartObjectWithChecksums()
|
||||||
testPutObject0ByteV2()
|
testPutObject0ByteV2()
|
||||||
testPutObjectNoLengthV2()
|
testPutObjectNoLengthV2()
|
||||||
testPutObjectsUnknownV2()
|
testPutObjectsUnknownV2()
|
||||||
|
|
4
vendor/github.com/minio/minio-go/v7/pkg/lifecycle/lifecycle.go
generated
vendored
4
vendor/github.com/minio/minio-go/v7/pkg/lifecycle/lifecycle.go
generated
vendored
|
@ -54,8 +54,8 @@ func (n AbortIncompleteMultipartUpload) MarshalXML(e *xml.Encoder, start xml.Sta
|
||||||
// specific period in the object's lifetime.
|
// specific period in the object's lifetime.
|
||||||
type NoncurrentVersionExpiration struct {
|
type NoncurrentVersionExpiration struct {
|
||||||
XMLName xml.Name `xml:"NoncurrentVersionExpiration" json:"-"`
|
XMLName xml.Name `xml:"NoncurrentVersionExpiration" json:"-"`
|
||||||
NoncurrentDays ExpirationDays `xml:"NoncurrentDays,omitempty"`
|
NoncurrentDays ExpirationDays `xml:"NoncurrentDays,omitempty" json:"NoncurrentDays,omitempty"`
|
||||||
NewerNoncurrentVersions int `xml:"NewerNoncurrentVersions,omitempty"`
|
NewerNoncurrentVersions int `xml:"NewerNoncurrentVersions,omitempty" json:"NewerNoncurrentVersions,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// MarshalXML if n is non-empty, i.e has a non-zero NoncurrentDays or NewerNoncurrentVersions.
|
// MarshalXML if n is non-empty, i.e has a non-zero NoncurrentDays or NewerNoncurrentVersions.
|
||||||
|
|
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
|
@ -384,7 +384,7 @@ github.com/miekg/dns
|
||||||
# github.com/minio/md5-simd v1.1.2
|
# github.com/minio/md5-simd v1.1.2
|
||||||
## explicit; go 1.14
|
## explicit; go 1.14
|
||||||
github.com/minio/md5-simd
|
github.com/minio/md5-simd
|
||||||
# github.com/minio/minio-go/v7 v7.0.52
|
# github.com/minio/minio-go/v7 v7.0.53
|
||||||
## explicit; go 1.17
|
## explicit; go 1.17
|
||||||
github.com/minio/minio-go/v7
|
github.com/minio/minio-go/v7
|
||||||
github.com/minio/minio-go/v7/pkg/credentials
|
github.com/minio/minio-go/v7/pkg/credentials
|
||||||
|
|
Loading…
Reference in a new issue