Skip to content
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

refactor GET object operations #824

Merged
merged 1 commit into from Sep 27, 2017
Merged

refactor GET object operations #824

merged 1 commit into from Sep 27, 2017

Conversation

aead
Copy link
Member

@aead aead commented Sep 25, 2017

This change refactors get-object calls to take GetOptions.
This is required to use client and server side encryption within
minio-go.

Updates #823

@poornas
Copy link
Contributor

poornas commented Sep 25, 2017

travis fail - your examples need to be updated.

@aead
Copy link
Member Author

aead commented Sep 25, 2017

Oh, yes, thanks @poornas 👍

@aead aead force-pushed the rf-get-object branch 2 times, most recently from 4daeec4 to f7ddad6 Compare September 26, 2017 00:02
api-stat.go Outdated
@@ -81,20 +81,19 @@ func extractObjMetadata(header http.Header) http.Header {
}

// StatObject verifies if object exists and you have permission to access.
func (c Client) StatObject(bucketName, objectName string) (ObjectInfo, error) {
func (c Client) StatObject(bucketName, objectName string, opts GetOptions) (ObjectInfo, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Api.md needs to document this.

func (c Client) GetObjectWithContext(ctx context.Context, bucketName, objectName string) (*Object, error) {
return c.getObjectWithContext(ctx, bucketName, objectName)
func (c Client) GetObjectWithContext(ctx context.Context, bucketName, objectName string, opts GetOptions) (*Object, error) {
return c.getObjectWithContext(ctx, bucketName, objectName, opts)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs documentation update for GetObjectWithContext and FGetObjectWithContext

http.Header
// GetOptions are used to specify additional headers or options
// during GET requests.
type GetOptions struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we rename this GetObjectOptions to be symmetric to the PutObjectOptions

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My plan was to rename PutObjectOptions -> PutOptions during encryption refactoring.
I can ask Harsha

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually it is more consistent to keep GetObjectOptions() instead of GetOptions() GetOptions is just too generic.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay

@@ -72,7 +72,7 @@ func (c Client) fGetObjectWithContext(ctx context.Context, bucketName, objectNam
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

needs a FGetEncryptedObject variant to match the FPutEncryptedObject.

docs/API.md Outdated
@@ -831,7 +870,7 @@ if err != nil {
}
```
<a name="StatObject"></a>
### StatObject(bucketName, objectName string) (ObjectInfo, error)
### StatObject(bucketName, objectName string, opts GetObjectOptions) (ObjectInfo, error)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks odd to pass GetObjectOptions to a HEAD call.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is a SSE-C call requires encryption keys - Otherwise there would be no way to get stats of an SSE-C object...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps StatObject(bucketName, objectName string, opts StatObjectOptions) --> GetObjectOptions --> StatObjectOptions

@@ -47,7 +47,7 @@ func main() {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Minute)
defer cancel()

reader, err := s3Client.GetObjectWithContext(ctx, "my-bucketname", "my-objectname")
reader, err := s3Client.GetObjectWithContext(ctx, "my-bucketname", "my-objectname", minio.GetObjectOptions{})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be good to have the example demonstrate use of the options

@harshavardhana
Copy link
Member

Looks like there is a formatting issue @aead can you fix?

@poornas
Copy link
Contributor

poornas commented Sep 27, 2017

@aead, travis fails for the example. A couple of minor additions required - FGetEncryptedObject test needed for functional tests. Also believe readme.md is missing link to the example. Are we going to have a StatObjectOptions?

@harshavardhana
Copy link
Member

harshavardhana commented Sep 27, 2017

@aead, travis fails for the example. A couple of minor additions required - FGetEncryptedObject test needed for functional tests. Also believe readme.md is missing link to the example. Are we going to have a StatObjectOptions?

We can have a simple

// GetObjectOptions are used to specify additional headers or options
// during GET requests.
type GetObjectOptions struct {
	headers map[string]string

	UserMetadata map[string]string
	Materials    encrypt.Materials
}

type StatObjectOptions GetObjectOptions

@aead
Copy link
Member Author

aead commented Sep 27, 2017

@harshavardhana
Won't work nicely. The problem is that we would use Go's type system in a wrong way.
E.g. All functions of GetObjectOptions are not accessible (strong type system).
A solution would be:

type StatObjectOptions struct {
     GetObjectOptions
}

But this will lead to weird constructions like StatObjectOptions{GetObjectObptions{}}

@harshavardhana
Copy link
Member

A solution would be:

type StatObjectOptions struct {
GetObjectOptions
}
But this will lead to weird constructions like StatObjectOptions{GetObjectObptions{}}

This would be do-able

type StatObjectOptions struct {
     GetObjectOptions
}

StatObjectOptions{} would initialize properly and inherit all the methods.

func NewHeadReqHeaders() RequestHeaders {
return RequestHeaders{
Header: make(http.Header),
// set adds a key value pair to the options. The

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment on exported method GetObjectOptions.Set should be of the form "Set ..."

@aead aead force-pushed the rf-get-object branch 3 times, most recently from ea523f8 to eb3e78a Compare September 27, 2017 20:23
Copy link
Contributor

@poornas poornas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Needs rebase

This change refactors get-object calls to take GetOptions.
This is required to use client and server side encryption within
minio-go.
@deekoder deekoder merged commit cb3571b into minio:master Sep 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants