Fix style issues. #15

This commit is contained in:
Andrey Smirnov
2014-07-17 18:09:13 +04:00
parent c54406e29f
commit 076ecd586f
3 changed files with 10 additions and 9 deletions

View File

@@ -23,6 +23,7 @@ var (
_ aptly.PublishedStorage = (*PublishedStorage)(nil) _ aptly.PublishedStorage = (*PublishedStorage)(nil)
) )
// NewPublishedStorageRaw creates published storage from raw aws credentials
func NewPublishedStorageRaw(auth aws.Auth, region aws.Region, bucket, defaultACL, prefix string) (*PublishedStorage, error) { func NewPublishedStorageRaw(auth aws.Auth, region aws.Region, bucket, defaultACL, prefix string) (*PublishedStorage, error) {
if defaultACL == "" { if defaultACL == "" {
defaultACL = "private" defaultACL = "private"
@@ -163,14 +164,14 @@ func (storage *PublishedStorage) Filelist(prefix string) ([]string, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
last_key := "" lastKey := ""
for _, key := range contents.Contents { for _, key := range contents.Contents {
if prefix == "" { if prefix == "" {
result = append(result, key.Key) result = append(result, key.Key)
} else { } else {
result = append(result, key.Key[len(prefix):]) result = append(result, key.Key[len(prefix):])
} }
last_key = key.Key lastKey = key.Key
} }
if contents.IsTruncated { if contents.IsTruncated {
marker = contents.NextMarker marker = contents.NextMarker
@@ -179,7 +180,7 @@ func (storage *PublishedStorage) Filelist(prefix string) ([]string, error) {
// NextMarker and it is truncated, you can use the value of the // NextMarker and it is truncated, you can use the value of the
// last Key in the response as the marker in the subsequent // last Key in the response as the marker in the subsequent
// request to get the next set of object keys. // request to get the next set of object keys.
marker = last_key marker = lastKey
} }
} else { } else {
break break

View File

@@ -9,8 +9,8 @@ import (
) )
type PublishedStorageSuite struct { type PublishedStorageSuite struct {
srv *s3test.Server srv *s3test.Server
storage, prefixed_storage *PublishedStorage storage, prefixedStorage *PublishedStorage
} }
var _ = Suite(&PublishedStorageSuite{}) var _ = Suite(&PublishedStorageSuite{})
@@ -25,7 +25,7 @@ func (s *PublishedStorageSuite) SetUpTest(c *C) {
s.storage, err = NewPublishedStorageRaw(auth, aws.Region{Name: "test-1", S3Endpoint: s.srv.URL(), S3LocationConstraint: true}, "test", "", "") s.storage, err = NewPublishedStorageRaw(auth, aws.Region{Name: "test-1", S3Endpoint: s.srv.URL(), S3LocationConstraint: true}, "test", "", "")
c.Assert(err, IsNil) c.Assert(err, IsNil)
s.prefixed_storage, err = NewPublishedStorageRaw(auth, aws.Region{Name: "test-1", S3Endpoint: s.srv.URL(), S3LocationConstraint: true}, "test", "", "lala") s.prefixedStorage, err = NewPublishedStorageRaw(auth, aws.Region{Name: "test-1", S3Endpoint: s.srv.URL(), S3LocationConstraint: true}, "test", "", "lala")
c.Assert(err, IsNil) c.Assert(err, IsNil)
err = s.storage.s3.Bucket("test").PutBucket("private") err = s.storage.s3.Bucket("test").PutBucket("private")
@@ -54,7 +54,7 @@ func (s *PublishedStorageSuite) TestPutFile(c *C) {
c.Check(err, IsNil) c.Check(err, IsNil)
c.Check(data, DeepEquals, []byte("welcome to s3!")) c.Check(data, DeepEquals, []byte("welcome to s3!"))
err = s.prefixed_storage.PutFile("a/b.txt", filepath.Join(dir, "a")) err = s.prefixedStorage.PutFile("a/b.txt", filepath.Join(dir, "a"))
c.Check(err, IsNil) c.Check(err, IsNil)
data, err = s.storage.bucket.Get("lala/a/b.txt") data, err = s.storage.bucket.Get("lala/a/b.txt")
@@ -81,7 +81,7 @@ func (s *PublishedStorageSuite) TestFilelist(c *C) {
c.Check(err, IsNil) c.Check(err, IsNil)
c.Check(list, DeepEquals, []string{}) c.Check(list, DeepEquals, []string{})
list, err = s.prefixed_storage.Filelist("") list, err = s.prefixedStorage.Filelist("")
c.Check(err, IsNil) c.Check(err, IsNil)
c.Check(list, DeepEquals, []string{"a", "b", "c"}) c.Check(list, DeepEquals, []string{"a", "b", "c"})
} }

View File

@@ -1,2 +1,2 @@
// Package files handles publishing to S3 // Package s3 handles publishing to Amazon S3
package s3 package s3