Simplify client interface
This commit is contained in:
+8
-8
@@ -64,7 +64,7 @@ type AccessMessage struct {
|
||||
Operation string `json:"operation"`
|
||||
Status string `json:"status"`
|
||||
Bucket string `json:"bucket"`
|
||||
Perms bucketPerms `json:"permission"`
|
||||
Perms accessPerms `json:"permission"`
|
||||
}
|
||||
|
||||
// String colorized access message
|
||||
@@ -99,8 +99,8 @@ func checkAccessSyntax(ctx *cli.Context) {
|
||||
if len(ctx.Args().Tail()) < 2 {
|
||||
cli.ShowCommandHelpAndExit(ctx, "access", 1) // last argument is exit code
|
||||
}
|
||||
perms := bucketPerms(ctx.Args().Tail().Get(0))
|
||||
if !perms.isValidBucketPERM() {
|
||||
perms := accessPerms(ctx.Args().Tail().Get(0))
|
||||
if !perms.isValidAccessPERM() {
|
||||
fatalIf(errDummy().Trace(),
|
||||
"Unrecognized permission ‘"+perms.String()+"’. Allowed values are [private, public, readonly].")
|
||||
}
|
||||
@@ -140,7 +140,7 @@ func mainAccess(ctx *cli.Context) {
|
||||
|
||||
switch ctx.Args().Get(0) {
|
||||
case "set":
|
||||
perms := bucketPerms(ctx.Args().Tail().Get(0))
|
||||
perms := accessPerms(ctx.Args().Tail().Get(0))
|
||||
for _, arg := range ctx.Args().Tail().Tail() {
|
||||
targetURL := getAliasURL(arg, config.Aliases)
|
||||
|
||||
@@ -169,23 +169,23 @@ func mainAccess(ctx *cli.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
func doSetAccess(targetURL string, targetPERMS bucketPerms) *probe.Error {
|
||||
func doSetAccess(targetURL string, targetPERMS accessPerms) *probe.Error {
|
||||
clnt, err := url2Client(targetURL)
|
||||
if err != nil {
|
||||
return err.Trace(targetURL)
|
||||
}
|
||||
if err = clnt.SetBucketACL(targetPERMS.String()); err != nil {
|
||||
if err = clnt.SetBucketAccess(targetPERMS.String()); err != nil {
|
||||
return err.Trace(targetURL, targetPERMS.String())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func doGetAccess(targetURL string) (perms bucketPerms, err *probe.Error) {
|
||||
func doGetAccess(targetURL string) (perms accessPerms, err *probe.Error) {
|
||||
clnt, err := url2Client(targetURL)
|
||||
if err != nil {
|
||||
return "", err.Trace(targetURL)
|
||||
}
|
||||
acl, err := clnt.GetBucketACL()
|
||||
acl, err := clnt.GetBucketAccess()
|
||||
if err != nil {
|
||||
return "", err.Trace(targetURL)
|
||||
}
|
||||
|
||||
+25
-25
@@ -16,8 +16,8 @@
|
||||
|
||||
package main
|
||||
|
||||
// isValidBucketPERM - is provided acl string supported
|
||||
func (b bucketPerms) isValidBucketPERM() bool {
|
||||
// isValidAccessPERM - is provided acl string supported
|
||||
func (b accessPerms) isValidAccessPERM() bool {
|
||||
switch true {
|
||||
case b.isPrivate():
|
||||
fallthrough
|
||||
@@ -32,19 +32,19 @@ func (b bucketPerms) isValidBucketPERM() bool {
|
||||
}
|
||||
}
|
||||
|
||||
// bucketPerms - bucket level access control
|
||||
type bucketPerms string
|
||||
// accessPerms - access level access control
|
||||
type accessPerms string
|
||||
|
||||
// different types of ACL's currently supported for buckets
|
||||
// different types of ACL's currently supported for accesss
|
||||
const (
|
||||
bucketPrivate = bucketPerms("private")
|
||||
bucketReadOnly = bucketPerms("readonly")
|
||||
bucketPublic = bucketPerms("public")
|
||||
bucketAuthorized = bucketPerms("authorized")
|
||||
accessPrivate = accessPerms("private")
|
||||
accessReadOnly = accessPerms("readonly")
|
||||
accessPublic = accessPerms("public")
|
||||
accessAuthorized = accessPerms("authorized")
|
||||
)
|
||||
|
||||
func (b bucketPerms) String() string {
|
||||
if !b.isValidBucketPERM() {
|
||||
func (b accessPerms) String() string {
|
||||
if !b.isValidAccessPERM() {
|
||||
return string(b)
|
||||
}
|
||||
if b.isReadOnly() {
|
||||
@@ -59,37 +59,37 @@ func (b bucketPerms) String() string {
|
||||
return "private"
|
||||
}
|
||||
|
||||
func aclToPerms(acl string) bucketPerms {
|
||||
func aclToPerms(acl string) accessPerms {
|
||||
switch acl {
|
||||
case "private":
|
||||
return bucketPerms("private")
|
||||
return accessPerms("private")
|
||||
case "public-read":
|
||||
return bucketPerms("readonly")
|
||||
return accessPerms("readonly")
|
||||
case "public-read-write":
|
||||
return bucketPerms("public")
|
||||
return accessPerms("public")
|
||||
case "authenticated-read":
|
||||
return bucketPerms("authorized")
|
||||
return accessPerms("authorized")
|
||||
default:
|
||||
return bucketPerms(acl)
|
||||
return accessPerms(acl)
|
||||
}
|
||||
}
|
||||
|
||||
// IsPrivate - is acl Private
|
||||
func (b bucketPerms) isPrivate() bool {
|
||||
return b == bucketPrivate
|
||||
func (b accessPerms) isPrivate() bool {
|
||||
return b == accessPrivate
|
||||
}
|
||||
|
||||
// IsPublicRead - is acl PublicRead
|
||||
func (b bucketPerms) isReadOnly() bool {
|
||||
return b == bucketReadOnly
|
||||
func (b accessPerms) isReadOnly() bool {
|
||||
return b == accessReadOnly
|
||||
}
|
||||
|
||||
// IsPublicReadWrite - is acl PublicReadWrite
|
||||
func (b bucketPerms) isPublic() bool {
|
||||
return b == bucketPublic
|
||||
func (b accessPerms) isPublic() bool {
|
||||
return b == accessPublic
|
||||
}
|
||||
|
||||
// IsAuthorized - is acl AuthorizedRead
|
||||
func (b bucketPerms) isAuthorized() bool {
|
||||
return b == bucketAuthorized
|
||||
func (b accessPerms) isAuthorized() bool {
|
||||
return b == accessAuthorized
|
||||
}
|
||||
|
||||
+1
-1
@@ -91,7 +91,7 @@ func catURL(sourceURL string) *probe.Error {
|
||||
return err.Trace(URL)
|
||||
}
|
||||
// Ignore size, since os.Stat() would not return proper size all the time for local filesystem for example /proc files.
|
||||
reader, _, err = sourceClnt.GetObject(0, 0)
|
||||
reader, _, err = sourceClnt.Get(0, 0)
|
||||
if err != nil {
|
||||
return err.Trace(URL)
|
||||
}
|
||||
|
||||
+3
-3
@@ -55,7 +55,7 @@ func getSource(sourceURL string) (reader io.ReadCloser, length int64, err *probe
|
||||
if err != nil {
|
||||
return nil, 0, err.Trace()
|
||||
}
|
||||
return sourceClnt.GetObject(0, 0)
|
||||
return sourceClnt.Get(0, 0)
|
||||
}
|
||||
|
||||
// putTarget writes to URL from reader. If length=0, read until EOF.
|
||||
@@ -64,7 +64,7 @@ func putTarget(targetURL string, length int64, reader io.Reader) *probe.Error {
|
||||
if err != nil {
|
||||
return err.Trace(targetURL)
|
||||
}
|
||||
err = targetClnt.PutObject(length, reader)
|
||||
err = targetClnt.Put(length, reader)
|
||||
if err != nil {
|
||||
return err.Trace(targetURL)
|
||||
}
|
||||
@@ -126,7 +126,7 @@ func putTargets(targetURLs []string, length int64, reader io.Reader) *probe.Erro
|
||||
go func(targetClient client.Client, reader io.ReadCloser, errorCh chan<- *probe.Error) {
|
||||
defer wg.Done()
|
||||
defer reader.Close()
|
||||
err := targetClient.PutObject(length, reader)
|
||||
err := targetClient.Put(length, reader)
|
||||
if err != nil {
|
||||
errorCh <- err.Trace()
|
||||
return
|
||||
|
||||
+10
-10
@@ -187,23 +187,23 @@ func (s *TestSuite) TestArgs2URL(c *C) {
|
||||
}
|
||||
|
||||
func (s *TestSuite) TestValidPERMS(c *C) {
|
||||
perms := bucketPerms("private")
|
||||
c.Assert(perms.isValidBucketPERM(), Equals, true)
|
||||
perms := accessPerms("private")
|
||||
c.Assert(perms.isValidAccessPERM(), Equals, true)
|
||||
c.Assert(perms.String(), Equals, "private")
|
||||
perms = bucketPerms("public")
|
||||
c.Assert(perms.isValidBucketPERM(), Equals, true)
|
||||
perms = accessPerms("public")
|
||||
c.Assert(perms.isValidAccessPERM(), Equals, true)
|
||||
c.Assert(perms.String(), Equals, "public-read-write")
|
||||
perms = bucketPerms("readonly")
|
||||
c.Assert(perms.isValidBucketPERM(), Equals, true)
|
||||
perms = accessPerms("readonly")
|
||||
c.Assert(perms.isValidAccessPERM(), Equals, true)
|
||||
c.Assert(perms.String(), Equals, "public-read")
|
||||
perms = bucketPerms("authorized")
|
||||
c.Assert(perms.isValidBucketPERM(), Equals, true)
|
||||
perms = accessPerms("authorized")
|
||||
c.Assert(perms.isValidAccessPERM(), Equals, true)
|
||||
c.Assert(perms.String(), Equals, "authenticated-read")
|
||||
}
|
||||
|
||||
func (s *TestSuite) TestInvalidPERMS(c *C) {
|
||||
perms := bucketPerms("invalid")
|
||||
c.Assert(perms.isValidBucketPERM(), Equals, false)
|
||||
perms := accessPerms("invalid")
|
||||
c.Assert(perms.isValidAccessPERM(), Equals, false)
|
||||
}
|
||||
|
||||
func (s *TestSuite) TestGetMcConfigDir(c *C) {
|
||||
|
||||
@@ -32,14 +32,18 @@ type Client interface {
|
||||
|
||||
// Bucket operations
|
||||
MakeBucket() *probe.Error
|
||||
GetBucketACL() (acl string, error *probe.Error)
|
||||
SetBucketACL(acl string) *probe.Error
|
||||
GetBucketAccess() (access string, error *probe.Error)
|
||||
SetBucketAccess(access string) *probe.Error
|
||||
|
||||
// Object operations
|
||||
// I/O operations
|
||||
Get(offset, length int64) (body io.ReadCloser, size int64, err *probe.Error)
|
||||
Put(size int64, data io.Reader) *probe.Error
|
||||
|
||||
// I/O operations with expiration
|
||||
ShareDownload(expires time.Duration) (string, *probe.Error)
|
||||
ShareUpload(bool, time.Duration, string) (map[string]string, *probe.Error)
|
||||
GetObject(offset, length int64) (body io.ReadCloser, size int64, err *probe.Error)
|
||||
PutObject(size int64, data io.Reader) *probe.Error
|
||||
|
||||
// Delete operations
|
||||
Remove() *probe.Error
|
||||
RemoveIncompleteUpload() *probe.Error
|
||||
|
||||
|
||||
+10
-10
@@ -100,8 +100,8 @@ func (f *fsClient) fsStat() (os.FileInfo, *probe.Error) {
|
||||
return st, nil
|
||||
}
|
||||
|
||||
// PutObject - create a new file
|
||||
func (f *fsClient) PutObject(size int64, data io.Reader) *probe.Error {
|
||||
// Put - create a new file
|
||||
func (f *fsClient) Put(size int64, data io.Reader) *probe.Error {
|
||||
objectDir, _ := filepath.Split(f.Path)
|
||||
objectPath := f.Path
|
||||
if objectDir != "" {
|
||||
@@ -153,10 +153,10 @@ func (f *fsClient) ShareUpload(recursive bool, expires time.Duration, contentTyp
|
||||
return nil, probe.NewError(client.APINotImplemented{API: "ShareUpload", APIType: "filesystem"})
|
||||
}
|
||||
|
||||
// GetObject download an full or part object from bucket
|
||||
// Get download an full or part object from bucket
|
||||
// getobject returns a reader, length and nil for no errors
|
||||
// with errors getobject will return nil reader, length and typed errors
|
||||
func (f *fsClient) GetObject(offset, length int64) (io.ReadCloser, int64, *probe.Error) {
|
||||
func (f *fsClient) Get(offset, length int64) (io.ReadCloser, int64, *probe.Error) {
|
||||
if offset < 0 || length < 0 {
|
||||
return nil, 0, probe.NewError(client.InvalidRange{Offset: offset})
|
||||
}
|
||||
@@ -507,14 +507,14 @@ func (f *fsClient) MakeBucket() *probe.Error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetBucketACL - get bucket acl
|
||||
func (f *fsClient) GetBucketACL() (acl string, error *probe.Error) {
|
||||
return "", probe.NewError(client.APINotImplemented{API: "GetBucketACL", APIType: "filesystem"})
|
||||
// GetBucketACL - get bucket access
|
||||
func (f *fsClient) GetBucketAccess() (acl string, error *probe.Error) {
|
||||
return "", probe.NewError(client.APINotImplemented{API: "GetBucketAccess", APIType: "filesystem"})
|
||||
}
|
||||
|
||||
// SetBucketACL - create a new bucket acl
|
||||
func (f *fsClient) SetBucketACL(acl string) *probe.Error {
|
||||
return probe.NewError(client.APINotImplemented{API: "SetBucketACL", APIType: "filesystem"})
|
||||
// SetBucketAccess - set bucket access
|
||||
func (f *fsClient) SetBucketAccess(acl string) *probe.Error {
|
||||
return probe.NewError(client.APINotImplemented{API: "SetBucketAccess", APIType: "filesystem"})
|
||||
}
|
||||
|
||||
// getFSMetadata -
|
||||
|
||||
+14
-14
@@ -47,14 +47,14 @@ func (s *MySuite) TestList(c *C) {
|
||||
data := "hello"
|
||||
dataLen := len(data)
|
||||
|
||||
perr = fsc.PutObject(int64(dataLen), bytes.NewReader([]byte(data)))
|
||||
perr = fsc.Put(int64(dataLen), bytes.NewReader([]byte(data)))
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
objectPath = filepath.Join(root, "object2")
|
||||
fsc, perr = fs.New(objectPath)
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
perr = fsc.PutObject(int64(dataLen), bytes.NewReader([]byte(data)))
|
||||
perr = fsc.Put(int64(dataLen), bytes.NewReader([]byte(data)))
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
fsc, perr = fs.New(root)
|
||||
@@ -79,7 +79,7 @@ func (s *MySuite) TestList(c *C) {
|
||||
fsc, perr = fs.New(objectPath)
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
perr = fsc.PutObject(int64(dataLen), bytes.NewReader([]byte(data)))
|
||||
perr = fsc.Put(int64(dataLen), bytes.NewReader([]byte(data)))
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
fsc, perr = fs.New(root)
|
||||
@@ -172,14 +172,14 @@ func (s *MySuite) TestBucketACLFails(c *C) {
|
||||
perr = fsc.MakeBucket()
|
||||
c.Assert(perr, IsNil)
|
||||
|
||||
perr = fsc.SetBucketACL("private")
|
||||
perr = fsc.SetBucketAccess("private")
|
||||
c.Assert(perr, Not(IsNil))
|
||||
|
||||
_, perr = fsc.GetBucketACL()
|
||||
_, perr = fsc.GetBucketAccess()
|
||||
c.Assert(perr, Not(IsNil))
|
||||
}
|
||||
|
||||
func (s *MySuite) TestPutObject(c *C) {
|
||||
func (s *MySuite) TestPut(c *C) {
|
||||
root, err := ioutil.TempDir(os.TempDir(), "fs-")
|
||||
c.Assert(err, IsNil)
|
||||
defer os.RemoveAll(root)
|
||||
@@ -191,11 +191,11 @@ func (s *MySuite) TestPutObject(c *C) {
|
||||
data := "hello"
|
||||
dataLen := len(data)
|
||||
|
||||
perr = fsc.PutObject(int64(dataLen), bytes.NewReader([]byte(data)))
|
||||
perr = fsc.Put(int64(dataLen), bytes.NewReader([]byte(data)))
|
||||
c.Assert(perr, IsNil)
|
||||
}
|
||||
|
||||
func (s *MySuite) TestGetObject(c *C) {
|
||||
func (s *MySuite) TestGet(c *C) {
|
||||
root, err := ioutil.TempDir(os.TempDir(), "fs-")
|
||||
c.Assert(err, IsNil)
|
||||
defer os.RemoveAll(root)
|
||||
@@ -207,10 +207,10 @@ func (s *MySuite) TestGetObject(c *C) {
|
||||
data := "hello"
|
||||
dataLen := len(data)
|
||||
|
||||
perr = fsc.PutObject(int64(dataLen), bytes.NewReader([]byte(data)))
|
||||
perr = fsc.Put(int64(dataLen), bytes.NewReader([]byte(data)))
|
||||
c.Assert(perr, IsNil)
|
||||
|
||||
reader, size, perr := fsc.GetObject(0, 0)
|
||||
reader, size, perr := fsc.Get(0, 0)
|
||||
c.Assert(perr, IsNil)
|
||||
var results bytes.Buffer
|
||||
_, err = io.CopyN(&results, reader, int64(size))
|
||||
@@ -219,7 +219,7 @@ func (s *MySuite) TestGetObject(c *C) {
|
||||
|
||||
}
|
||||
|
||||
func (s *MySuite) TestGetObjectRange(c *C) {
|
||||
func (s *MySuite) TestGetRange(c *C) {
|
||||
root, err := ioutil.TempDir(os.TempDir(), "fs-")
|
||||
c.Assert(err, IsNil)
|
||||
defer os.RemoveAll(root)
|
||||
@@ -231,10 +231,10 @@ func (s *MySuite) TestGetObjectRange(c *C) {
|
||||
data := "hello world"
|
||||
dataLen := len(data)
|
||||
|
||||
perr = fsc.PutObject(int64(dataLen), bytes.NewReader([]byte(data)))
|
||||
perr = fsc.Put(int64(dataLen), bytes.NewReader([]byte(data)))
|
||||
c.Assert(perr, IsNil)
|
||||
|
||||
reader, size, perr := fsc.GetObject(0, 5)
|
||||
reader, size, perr := fsc.Get(0, 5)
|
||||
c.Assert(perr, IsNil)
|
||||
var results bytes.Buffer
|
||||
_, err = io.CopyN(&results, reader, int64(size))
|
||||
@@ -254,7 +254,7 @@ func (s *MySuite) TestStatObject(c *C) {
|
||||
data := "hello"
|
||||
dataLen := len(data)
|
||||
|
||||
perr = fsc.PutObject(int64(dataLen), bytes.NewReader([]byte(data)))
|
||||
perr = fsc.Put(int64(dataLen), bytes.NewReader([]byte(data)))
|
||||
c.Assert(perr, IsNil)
|
||||
|
||||
content, perr := fsc.Stat()
|
||||
|
||||
@@ -66,8 +66,8 @@ func (c *s3Client) URL() *client.URL {
|
||||
return c.hostURL
|
||||
}
|
||||
|
||||
// GetObject - get object
|
||||
func (c *s3Client) GetObject(offset, length int64) (io.ReadCloser, int64, *probe.Error) {
|
||||
// Get - get object
|
||||
func (c *s3Client) Get(offset, length int64) (io.ReadCloser, int64, *probe.Error) {
|
||||
bucket, object := c.url2BucketAndObject()
|
||||
reader, metadata, err := c.api.GetPartialObject(bucket, object, offset, length)
|
||||
if err != nil {
|
||||
@@ -132,8 +132,8 @@ func (c *s3Client) ShareUpload(recursive bool, expires time.Duration, contentTyp
|
||||
return m, probe.NewError(err)
|
||||
}
|
||||
|
||||
// PutObject - put object
|
||||
func (c *s3Client) PutObject(size int64, data io.Reader) *probe.Error {
|
||||
// Put - put object
|
||||
func (c *s3Client) Put(size int64, data io.Reader) *probe.Error {
|
||||
// md5 is purposefully ignored since AmazonS3 does not return proper md5sum
|
||||
// for a multipart upload and there is no need to cross verify,
|
||||
// invidual parts are properly verified
|
||||
@@ -168,8 +168,8 @@ func (c *s3Client) MakeBucket() *probe.Error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetBucketACL get canned acl's on a bucket
|
||||
func (c *s3Client) GetBucketACL() (acl string, error *probe.Error) {
|
||||
// GetBucketAccess get canned acl on a bucket
|
||||
func (c *s3Client) GetBucketAccess() (acl string, error *probe.Error) {
|
||||
bucket, object := c.url2BucketAndObject()
|
||||
if object != "" {
|
||||
return "", probe.NewError(client.InvalidQueryURL{URL: c.hostURL.String()})
|
||||
@@ -181,8 +181,8 @@ func (c *s3Client) GetBucketACL() (acl string, error *probe.Error) {
|
||||
return bucketACL.String(), nil
|
||||
}
|
||||
|
||||
// SetBucketACL add canned acl's on a bucket
|
||||
func (c *s3Client) SetBucketACL(acl string) *probe.Error {
|
||||
// SetBucketAccess set canned acl on a bucket
|
||||
func (c *s3Client) SetBucketAccess(acl string) *probe.Error {
|
||||
bucket, object := c.url2BucketAndObject()
|
||||
if object != "" {
|
||||
return probe.NewError(client.InvalidQueryURL{URL: c.hostURL.String()})
|
||||
|
||||
@@ -140,7 +140,7 @@ func (s *MySuite) TestBucketOperations(c *C) {
|
||||
err = s3c.MakeBucket()
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
err = s3c.SetBucketACL("public-read-write")
|
||||
err = s3c.SetBucketAccess("public-read-write")
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
conf.HostURL = server.URL + string(s3c.URL().Separator)
|
||||
@@ -177,7 +177,7 @@ func (s *MySuite) TestObjectOperations(c *C) {
|
||||
s3c, err := New(conf)
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
err = s3c.PutObject(int64(len(object.data)), bytes.NewReader(object.data))
|
||||
err = s3c.Put(int64(len(object.data)), bytes.NewReader(object.data))
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
content, err := s3c.Stat()
|
||||
@@ -186,7 +186,7 @@ func (s *MySuite) TestObjectOperations(c *C) {
|
||||
c.Assert(content.Size, Equals, int64(len(object.data)))
|
||||
c.Assert(content.Type.IsRegular(), Equals, true)
|
||||
|
||||
reader, size, err := s3c.GetObject(0, 0)
|
||||
reader, size, err := s3c.Get(0, 0)
|
||||
c.Assert(size, Equals, int64(len(object.data)))
|
||||
|
||||
var buffer bytes.Buffer
|
||||
|
||||
@@ -66,8 +66,8 @@ func (c *s3Client) URL() *client.URL {
|
||||
return c.hostURL
|
||||
}
|
||||
|
||||
// GetObject - get object
|
||||
func (c *s3Client) GetObject(offset, length int64) (io.ReadCloser, int64, *probe.Error) {
|
||||
// Get - get object
|
||||
func (c *s3Client) Get(offset, length int64) (io.ReadCloser, int64, *probe.Error) {
|
||||
bucket, object := c.url2BucketAndObject()
|
||||
reader, metadata, err := c.api.GetPartialObject(bucket, object, offset, length)
|
||||
if err != nil {
|
||||
@@ -132,8 +132,8 @@ func (c *s3Client) ShareUpload(recursive bool, expires time.Duration, contentTyp
|
||||
return m, probe.NewError(err)
|
||||
}
|
||||
|
||||
// PutObject - put object
|
||||
func (c *s3Client) PutObject(size int64, data io.Reader) *probe.Error {
|
||||
// Put - put object
|
||||
func (c *s3Client) Put(size int64, data io.Reader) *probe.Error {
|
||||
// md5 is purposefully ignored since AmazonS3 does not return proper md5sum
|
||||
// for a multipart upload and there is no need to cross verify,
|
||||
// invidual parts are properly verified
|
||||
@@ -168,8 +168,8 @@ func (c *s3Client) MakeBucket() *probe.Error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetBucketACL get canned acl's on a bucket
|
||||
func (c *s3Client) GetBucketACL() (acl string, error *probe.Error) {
|
||||
// GetBucketAccess get canned acl on a bucket
|
||||
func (c *s3Client) GetBucketAccess() (acl string, error *probe.Error) {
|
||||
bucket, object := c.url2BucketAndObject()
|
||||
if object != "" {
|
||||
return "", probe.NewError(client.InvalidQueryURL{URL: c.hostURL.String()})
|
||||
@@ -181,8 +181,8 @@ func (c *s3Client) GetBucketACL() (acl string, error *probe.Error) {
|
||||
return bucketACL.String(), nil
|
||||
}
|
||||
|
||||
// SetBucketACL add canned acl's on a bucket
|
||||
func (c *s3Client) SetBucketACL(acl string) *probe.Error {
|
||||
// SetBucketAccess set canned acl on a bucket
|
||||
func (c *s3Client) SetBucketAccess(acl string) *probe.Error {
|
||||
bucket, object := c.url2BucketAndObject()
|
||||
if object != "" {
|
||||
return probe.NewError(client.InvalidQueryURL{URL: c.hostURL.String()})
|
||||
|
||||
@@ -140,7 +140,7 @@ func (s *MySuite) TestBucketOperations(c *C) {
|
||||
err = s3c.MakeBucket()
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
err = s3c.SetBucketACL("public-read-write")
|
||||
err = s3c.SetBucketAccess("public-read-write")
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
conf.HostURL = server.URL + string(s3c.URL().Separator)
|
||||
@@ -177,7 +177,7 @@ func (s *MySuite) TestObjectOperations(c *C) {
|
||||
s3c, err := New(conf)
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
err = s3c.PutObject(int64(len(object.data)), bytes.NewReader(object.data))
|
||||
err = s3c.Put(int64(len(object.data)), bytes.NewReader(object.data))
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
content, err := s3c.Stat()
|
||||
@@ -186,7 +186,7 @@ func (s *MySuite) TestObjectOperations(c *C) {
|
||||
c.Assert(content.Size, Equals, int64(len(object.data)))
|
||||
c.Assert(content.Type.IsRegular(), Equals, true)
|
||||
|
||||
reader, size, err := s3c.GetObject(0, 0)
|
||||
reader, size, err := s3c.Get(0, 0)
|
||||
c.Assert(size, Equals, int64(len(object.data)))
|
||||
|
||||
var buffer bytes.Buffer
|
||||
|
||||
+1
-1
@@ -227,7 +227,7 @@ func mainRm(ctx *cli.Context) {
|
||||
if len(args) != 1 {
|
||||
if len(args) == 2 && args.Get(0) == "force" && args.Get(1) == "incomplete" ||
|
||||
len(args) == 2 && args.Get(0) == "incomplete" && args.Get(1) == "force" {
|
||||
args = args[:len(args)]
|
||||
args = args[:]
|
||||
} else {
|
||||
if args.Last() == "force" {
|
||||
force = true
|
||||
|
||||
+2
-2
@@ -138,7 +138,7 @@ func getExperimentalUpdate() {
|
||||
clnt, err := url2Client(mcExperimentalURL)
|
||||
fatalIf(err.Trace(mcExperimentalURL), "Unable to initalize experimental URL.")
|
||||
|
||||
data, _, err := clnt.GetObject(0, 0)
|
||||
data, _, err := clnt.Get(0, 0)
|
||||
fatalIf(err.Trace(mcExperimentalURL), "Unable to read from experimental URL ‘"+mcExperimentalURL+"’.")
|
||||
|
||||
current, e := time.Parse(http.TimeFormat, mcVersion)
|
||||
@@ -180,7 +180,7 @@ func getReleaseUpdate() {
|
||||
clnt, err := url2Client(mcUpdateURL)
|
||||
fatalIf(err.Trace(mcUpdateURL), "Unable to initalize update URL.")
|
||||
|
||||
data, _, err := clnt.GetObject(0, 0)
|
||||
data, _, err := clnt.Get(0, 0)
|
||||
fatalIf(err.Trace(mcUpdateURL), "Unable to read from update URL ‘"+mcUpdateURL+"’.")
|
||||
|
||||
current, e := time.Parse(http.TimeFormat, mcVersion)
|
||||
|
||||
Reference in New Issue
Block a user