Skip to content

Commit

Permalink
api refactor Remove WithContext APIs move to v7 (minio#1307)
Browse files Browse the repository at this point in the history
  • Loading branch information
vadmeste authored Jun 23, 2020
1 parent a57fec8 commit e5cd2d1
Show file tree
Hide file tree
Showing 123 changed files with 1,240 additions and 2,224 deletions.
12 changes: 4 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This document assumes that you have a working [Go development environment](https

## Download from Github
```sh
GO111MODULE=on go get github.com/minio/minio-go/v6
GO111MODULE=on go get github.com/minio/minio-go/v7
```

## Initialize MinIO Client
Expand All @@ -17,7 +17,7 @@ MinIO client requires the following four parameters specified to connect to an A
| Parameter | Description|
| :--- | :--- |
| endpoint | URL to object storage service. |
| accessKeyID | Access key is the user ID that uniquely identifies your account. |
| accessKeyID | Access key is the user ID that uniquely identifies your account. |
| secretAccessKey | Secret key is the password to your account. |
| secure | Set this value to 'true' to enable secure (HTTPS) access. |

Expand All @@ -26,7 +26,7 @@ MinIO client requires the following four parameters specified to connect to an A
package main

import (
"github.com/minio/minio-go/v6"
"github.com/minio/minio-go/v7"
"log"
)

Expand Down Expand Up @@ -56,7 +56,7 @@ We will use the MinIO server running at [https://play.min.io](https://play.min.i
package main

import (
"github.com/minio/minio-go/v6"
"github.com/minio/minio-go/v7"
"log"
)

Expand Down Expand Up @@ -141,14 +141,10 @@ The full API Reference is available here.
### API Reference : File Object Operations
* [`FPutObject`](https://docs.min.io/docs/golang-client-api-reference#FPutObject)
* [`FGetObject`](https://docs.min.io/docs/golang-client-api-reference#FGetObject)
* [`FPutObjectWithContext`](https://docs.min.io/docs/golang-client-api-reference#FPutObjectWithContext)
* [`FGetObjectWithContext`](https://docs.min.io/docs/golang-client-api-reference#FGetObjectWithContext)

### API Reference : Object Operations
* [`GetObject`](https://docs.min.io/docs/golang-client-api-reference#GetObject)
* [`PutObject`](https://docs.min.io/docs/golang-client-api-reference#PutObject)
* [`GetObjectWithContext`](https://docs.min.io/docs/golang-client-api-reference#GetObjectWithContext)
* [`PutObjectWithContext`](https://docs.min.io/docs/golang-client-api-reference#PutObjectWithContext)
* [`PutObjectStreaming`](https://docs.min.io/docs/golang-client-api-reference#PutObjectStreaming)
* [`StatObject`](https://docs.min.io/docs/golang-client-api-reference#StatObject)
* [`CopyObject`](https://docs.min.io/docs/golang-client-api-reference#CopyObject)
Expand Down
24 changes: 8 additions & 16 deletions README_zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

MinIO Go Client SDK提供了简单的API来访问任何与Amazon S3兼容的对象存储服务。

**支持的云存储:**
**支持的云存储:**

- AWS Signature Version 4
- Amazon S3
Expand All @@ -26,10 +26,10 @@ go get -u github.com/minio/minio-go
## 初始化MinIO Client
MinIO client需要以下4个参数来连接与Amazon S3兼容的对象存储。

| 参数 | 描述|
| 参数 | 描述|
| :--- | :--- |
| endpoint | 对象存储服务的URL |
| accessKeyID | Access key是唯一标识你的账户的用户ID。 |
| endpoint | 对象存储服务的URL |
| accessKeyID | Access key是唯一标识你的账户的用户ID。 |
| secretAccessKey | Secret key是你账户的密码。 |
| secure | true代表使用HTTPS |

Expand All @@ -38,7 +38,7 @@ MinIO client需要以下4个参数来连接与Amazon S3兼容的对象存储。
package main

import (
"github.com/minio/minio-go/v6"
"github.com/minio/minio-go/v7"
"log"
)

Expand Down Expand Up @@ -68,7 +68,7 @@ func main() {
package main

import (
"github.com/minio/minio-go/v6"
"github.com/minio/minio-go/v7"
"log"
)

Expand Down Expand Up @@ -118,7 +118,7 @@ func main() {
### 运行FileUploader
```sh
go run file-uploader.go
2016/08/13 17:03:28 Successfully created mymusic
2016/08/13 17:03:28 Successfully created mymusic
2016/08/13 17:03:40 Successfully uploaded golden-oldies.zip of size 16253413

mc ls play/mymusic/
Expand Down Expand Up @@ -151,14 +151,10 @@ mc ls play/mymusic/
### API文档 : 操作文件对象
* [`FPutObject`](https://docs.min.io/docs/golang-client-api-reference#FPutObject)
* [`FGetObject`](https://docs.min.io/docs/golang-client-api-reference#FPutObject)
* [`FPutObjectWithContext`](https://docs.min.io/docs/golang-client-api-reference#FPutObjectWithContext)
* [`FGetObjectWithContext`](https://docs.min.io/docs/golang-client-api-reference#FGetObjectWithContext)

### API文档 : 操作对象
* [`GetObject`](https://docs.min.io/docs/golang-client-api-reference#GetObject)
* [`PutObject`](https://docs.min.io/docs/golang-client-api-reference#PutObject)
* [`GetObjectWithContext`](https://docs.min.io/docs/golang-client-api-reference#GetObjectWithContext)
* [`PutObjectWithContext`](https://docs.min.io/docs/golang-client-api-reference#PutObjectWithContext)
* [`PutObjectStreaming`](https://docs.min.io/docs/golang-client-api-reference#PutObjectStreaming)
* [`StatObject`](https://docs.min.io/docs/golang-client-api-reference#StatObject)
* [`CopyObject`](https://docs.min.io/docs/golang-client-api-reference#CopyObject)
Expand Down Expand Up @@ -197,7 +193,7 @@ mc ls play/mymusic/
* [setbucketpolicy.go](https://github.com/minio/minio-go/blob/master/examples/s3/setbucketpolicy.go)
* [getbucketpolicy.go](https://github.com/minio/minio-go/blob/master/examples/s3/getbucketpolicy.go)
* [listbucketpolicies.go](https://github.com/minio/minio-go/blob/master/examples/s3/listbucketpolicies.go)

### 完整示例 : 存储桶通知
* [setbucketnotification.go](https://github.com/minio/minio-go/blob/master/examples/s3/setbucketnotification.go)
* [getbucketnotification.go](https://github.com/minio/minio-go/blob/master/examples/s3/getbucketnotification.go)
Expand Down Expand Up @@ -238,7 +234,3 @@ mc ls play/mymusic/

## 贡献
[贡献指南](https://github.com/minio/minio-go/blob/master/docs/zh_CN/CONTRIBUTING.md)

[![Build Status](https://travis-ci.org/minio/minio-go.svg)](https://travis-ci.org/minio/minio-go)
[![Build status](https://ci.appveyor.com/api/projects/status/1d05e6nvxcelmrak?svg=true)](https://ci.appveyor.com/project/harshavardhana/minio-go)

34 changes: 11 additions & 23 deletions api-bucket-tagging.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,13 @@ import (
"net/http"
"net/url"

"github.com/minio/minio-go/v6/pkg/s3utils"
"github.com/minio/minio-go/v6/pkg/tags"
"github.com/minio/minio-go/v7/pkg/s3utils"
"github.com/minio/minio-go/v7/pkg/tags"
)

// GetBucketTagging gets tagging configuration for a bucket.
func (c Client) GetBucketTagging(bucketName string) (*tags.Tags, error) {
return c.GetBucketTaggingWithContext(context.Background(), bucketName)
}

// GetBucketTaggingWithContext gets tagging configuration for a bucket with a context to control cancellations and timeouts.
func (c Client) GetBucketTaggingWithContext(ctx context.Context, bucketName string) (*tags.Tags, error) {
// GetBucketTagging fetch tagging configuration for a bucket with a
// context to control cancellations and timeouts.
func (c Client) GetBucketTagging(ctx context.Context, bucketName string) (*tags.Tags, error) {
// Input validation.
if err := s3utils.CheckValidBucketName(bucketName); err != nil {
return nil, err
Expand Down Expand Up @@ -66,13 +62,9 @@ func (c Client) GetBucketTaggingWithContext(ctx context.Context, bucketName stri
return tags.ParseBucketXML(resp.Body)
}

// SetBucketTagging sets tagging configuration for a bucket.
func (c Client) SetBucketTagging(bucketName string, tags *tags.Tags) error {
return c.SetBucketTaggingWithContext(context.Background(), bucketName, tags)
}

// SetBucketTaggingWithContext sets tagging configuration for a bucket with a context to control cancellations and timeouts.
func (c Client) SetBucketTaggingWithContext(ctx context.Context, bucketName string, tags *tags.Tags) error {
// SetBucketTagging sets tagging configuration for a bucket
// with a context to control cancellations and timeouts.
func (c Client) SetBucketTagging(ctx context.Context, bucketName string, tags *tags.Tags) error {
// Input validation.
if err := s3utils.CheckValidBucketName(bucketName); err != nil {
return err
Expand Down Expand Up @@ -113,13 +105,9 @@ func (c Client) SetBucketTaggingWithContext(ctx context.Context, bucketName stri
return nil
}

// DeleteBucketTagging removes tagging configuration for a bucket.
func (c Client) DeleteBucketTagging(bucketName string) error {
return c.DeleteBucketTaggingWithContext(context.Background(), bucketName)
}

// DeleteBucketTaggingWithContext removes tagging configuration for a bucket with a context to control cancellations and timeouts.
func (c Client) DeleteBucketTaggingWithContext(ctx context.Context, bucketName string) error {
// DeleteBucketTagging removes tagging configuration for a
// bucket with a context to control cancellations and timeouts.
func (c Client) DeleteBucketTagging(ctx context.Context, bucketName string) error {
// Input validation.
if err := s3utils.CheckValidBucketName(bucketName); err != nil {
return err
Expand Down
27 changes: 11 additions & 16 deletions api-compose-object.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ import (
"strings"
"time"

"github.com/minio/minio-go/v6/pkg/encrypt"
"github.com/minio/minio-go/v6/pkg/s3utils"
"github.com/minio/minio-go/v7/pkg/encrypt"
"github.com/minio/minio-go/v7/pkg/s3utils"
)

// DestinationInfo - type with information about the object to be
Expand Down Expand Up @@ -408,17 +408,12 @@ func (c Client) uploadPartCopy(ctx context.Context, bucket, object, uploadID str
return p, nil
}

// ComposeObjectWithProgress is a wrapper for ComposeObjectWithProgressWithContext.
func (c Client) ComposeObjectWithProgress(dst DestinationInfo, srcs []SourceInfo, progress io.Reader) error {
return c.ComposeObjectWithProgressWithContext(context.Background(), dst, srcs, progress)
}

// ComposeObjectWithProgressWithContext - creates an object using server-side copying of
// existing objects. It takes a list of source objects (with optional
// offsets) and concatenates them into a new object using only
// server-side copying operations. Optionally takes progress reader hook
// for applications to look at current progress.
func (c Client) ComposeObjectWithProgressWithContext(ctx context.Context, dst DestinationInfo, srcs []SourceInfo, progress io.Reader) error {
// ComposeObjectWithProgress - creates an object using server-side copying
// of existing objects. It takes a list of source objects (with optional offsets)
// and concatenates them into a new object using only server-side copying
// operations. Optionally takes progress reader hook for applications to
// look at current progress.
func (c Client) ComposeObjectWithProgress(ctx context.Context, dst DestinationInfo, srcs []SourceInfo, progress io.Reader) error {
if len(srcs) < 1 || len(srcs) > maxPartsCount {
return ErrInvalidArgument("There must be as least one and up to 10000 source objects.")
}
Expand Down Expand Up @@ -482,7 +477,7 @@ func (c Client) ComposeObjectWithProgressWithContext(ctx context.Context, dst De
// involved, it is being copied wholly and at most 5GiB in
// size, emptyfiles are also supported).
if (totalParts == 1 && srcs[0].start == -1 && totalSize <= maxPartSize) || (totalSize == 0) {
return c.CopyObjectWithProgressWithContext(ctx, dst, srcs[0], progress)
return c.CopyObjectWithProgress(ctx, dst, srcs[0], progress)
}

// Now, handle multipart-copy cases.
Expand Down Expand Up @@ -566,8 +561,8 @@ func (c Client) ComposeObjectWithProgressWithContext(ctx context.Context, dst De
// existing objects. It takes a list of source objects (with optional
// offsets) and concatenates them into a new object using only
// server-side copying operations.
func (c Client) ComposeObject(dst DestinationInfo, srcs []SourceInfo) error {
return c.ComposeObjectWithProgress(dst, srcs, nil)
func (c Client) ComposeObject(ctx context.Context, dst DestinationInfo, srcs []SourceInfo) error {
return c.ComposeObjectWithProgress(ctx, dst, srcs, nil)
}

// partsRequired is maximum parts possible with
Expand Down
2 changes: 1 addition & 1 deletion api-error-response.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ type ErrorResponse struct {
//
// For example:
//
// import s3 "github.com/minio/minio-go/v6"
// import s3 "github.com/minio/minio-go/v7"
// ...
// ...
// reader, stat, err := s3.GetObject(...)
Expand Down
12 changes: 4 additions & 8 deletions api-get-bucket-encryption.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,12 @@ import (
"net/http"
"net/url"

"github.com/minio/minio-go/v6/pkg/s3utils"
"github.com/minio/minio-go/v7/pkg/s3utils"
)

// GetBucketEncryption - get default encryption configuration for a bucket.
func (c Client) GetBucketEncryption(bucketName string) (ServerSideEncryptionConfiguration, error) {
return c.GetBucketEncryptionWithContext(context.Background(), bucketName)
}

// GetBucketEncryptionWithContext gets the default encryption configuration on an existing bucket with a context to control cancellations and timeouts.
func (c Client) GetBucketEncryptionWithContext(ctx context.Context, bucketName string) (ServerSideEncryptionConfiguration, error) {
// GetBucketEncryption gets the default encryption configuration
// on an existing bucket with a context to control cancellations and timeouts.
func (c Client) GetBucketEncryption(ctx context.Context, bucketName string) (ServerSideEncryptionConfiguration, error) {
// Input validation.
if err := s3utils.CheckValidBucketName(bucketName); err != nil {
return ServerSideEncryptionConfiguration{}, err
Expand Down
14 changes: 5 additions & 9 deletions api-get-bucket-versioning.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,19 @@ import (
"net/http"
"net/url"

"github.com/minio/minio-go/v6/pkg/s3utils"
"github.com/minio/minio-go/v7/pkg/s3utils"
)

// BucketVersioningConfiguration is the versioning configuration structure
type BucketVersioningConfiguration struct {
XMLName xml.Name `xml:"VersioningConfiguration"`
Status string `xml:"Status"`
MfaDelete string `xml:"MfaDelete,omitempty"`
MFADelete string `xml:"MfaDelete,omitempty"`
}

// GetBucketVersioning - get versioning configuration for a bucket.
func (c Client) GetBucketVersioning(bucketName string) (BucketVersioningConfiguration, error) {
return c.GetBucketVersioningWithContext(context.Background(), bucketName)
}

// GetBucketVersioningWithContext gets the versioning configuration on an existing bucket with a context to control cancellations and timeouts.
func (c Client) GetBucketVersioningWithContext(ctx context.Context, bucketName string) (BucketVersioningConfiguration, error) {
// GetBucketVersioning gets the versioning configuration on
// an existing bucket with a context to control cancellations and timeouts.
func (c Client) GetBucketVersioning(ctx context.Context, bucketName string) (BucketVersioningConfiguration, error) {
// Input validation.
if err := s3utils.CheckValidBucketName(bucketName); err != nil {
return BucketVersioningConfiguration{}, err
Expand Down
11 changes: 3 additions & 8 deletions api-get-lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,11 @@ import (
"net/http"
"net/url"

"github.com/minio/minio-go/v6/pkg/s3utils"
"github.com/minio/minio-go/v7/pkg/s3utils"
)

// GetBucketLifecycle is a wrapper for GetBucketLifecycleWithContext.
func (c Client) GetBucketLifecycle(bucketName string) (string, error) {
return c.GetBucketLifecycleWithContext(context.Background(), bucketName)
}

// GetBucketLifecycleWithContext - get bucket lifecycle.
func (c Client) GetBucketLifecycleWithContext(ctx context.Context, bucketName string) (string, error) {
// GetBucketLifecycle fetch bucket lifecycle configuration
func (c Client) GetBucketLifecycle(ctx context.Context, bucketName string) (string, error) {
// Input validation.
if err := s3utils.CheckValidBucketName(bucketName); err != nil {
return "", err
Expand Down
Loading

0 comments on commit e5cd2d1

Please sign in to comment.