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

Fix golint errors #238

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion b2/item.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (i *item) Metadata() (map[string]interface{}, error) {
return i.metadata, nil
}

// size returns the file's size, in bytes
// Size returns the file's size, in bytes
func (i *item) Size() (int64, error) {
return i.size, nil
}
Expand Down
4 changes: 2 additions & 2 deletions google/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (

stowLoc, err := stow.Dial(stowgs.Kind, stow.ConfigMap{
stowgs.ConfigJSON: "<json config>",
stowgs.ConfigProjectId: "<project id>",
stowgs.ConfigProjectID: "<project id>",
})
if err != nil {
log.Fatal(err)
Expand All @@ -46,7 +46,7 @@ By default, Stow uses `https://www.googleapis.com/auth/devstorage.read_write` sc
```go
stowLoc, err := stow.Dial(stowgs.Kind, stow.ConfigMap{
stowgs.ConfigJSON: "<json config>",
stowgs.ConfigProjectId: "<project id>",
stowgs.ConfigProjectID: "<project id>",
stowgs.ConfigScopes: "<scope_1>,<scope_2>",
})
```
Expand Down
14 changes: 8 additions & 6 deletions google/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ import (
const Kind = "google"

const (
// The service account json blob
ConfigJSON = "json"
ConfigProjectId = "project_id"
ConfigScopes = "scopes"
// ConfigJSON is a key whose value is the path of the JSON configuration file
ConfigJSON = "json"
// ConfigProjectID is a key whose value is the Project ID
ConfigProjectID = "project_id"
// ConfigScopes is a key with a comma separated list of scopes as its value.
ConfigScopes = "scopes"
)

func init() {
Expand All @@ -31,7 +33,7 @@ func init() {
return errors.New("missing JSON configuration")
}

_, ok = config.Config(ConfigProjectId)
_, ok = config.Config(ConfigProjectID)
if !ok {
return errors.New("missing Project ID")
}
Expand All @@ -43,7 +45,7 @@ func init() {
return nil, errors.New("missing JSON configuration")
}

_, ok = config.Config(ConfigProjectId)
_, ok = config.Config(ConfigProjectID)
if !ok {
return nil, errors.New("missing Project ID")
}
Expand Down
9 changes: 6 additions & 3 deletions google/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
storage "google.golang.org/api/storage/v1"
)

// Container for the Google Storage Service.
type Container struct {
// Name is needed to retrieve items.
name string
Expand All @@ -27,6 +28,7 @@ func (c *Container) Name() string {
return c.name
}

// Bucket returns the storage bucket.
func (c *Container) Bucket() (*storage.Bucket, error) {
return c.client.Buckets.Get(c.name).Do()
}
Expand All @@ -44,7 +46,7 @@ func (c *Container) Item(id string) (stow.Item, error) {
return nil, err
}

u, err := prepUrl(res.MediaLink)
u, err := prepURL(res.MediaLink)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -96,7 +98,7 @@ func (c *Container) Items(prefix string, cursor string, count int) ([]stow.Item,
return nil, "", err
}

u, err := prepUrl(o.MediaLink)
u, err := prepURL(o.MediaLink)
if err != nil {
return nil, "", err
}
Expand All @@ -123,6 +125,7 @@ func (c *Container) Items(prefix string, cursor string, count int) ([]stow.Item,
return containerItems, res.NextPageToken, nil
}

// RemoveItem identifies the file by it's ID, then removes all versions of that file
func (c *Container) RemoveItem(id string) error {
return c.client.Objects.Delete(c.name, id).Do()
}
Expand Down Expand Up @@ -151,7 +154,7 @@ func (c *Container) Put(name string, r io.Reader, size int64, metadata map[strin
return nil, err
}

u, err := prepUrl(res.MediaLink)
u, err := prepURL(res.MediaLink)
if err != nil {
return nil, err
}
Expand Down
7 changes: 4 additions & 3 deletions google/item.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
storage "google.golang.org/api/storage/v1"
)

// Item within the Google Storage Service.
type Item struct {
container *Container // Container information is required by a few methods.
client *storage.Service // A client is needed to make requests.
Expand Down Expand Up @@ -69,13 +70,13 @@ func (i *Item) ETag() (string, error) {
return i.etag, nil
}

// Object returns the Google Storage Object
// StorageObject returns the Google Storage Object
func (i *Item) StorageObject() *storage.Object {
return i.object
}

// prepUrl takes a MediaLink string and returns a url
func prepUrl(str string) (*url.URL, error) {
// prepURL takes a MediaLink string and returns a url
func prepURL(str string) (*url.URL, error) {
u, err := url.Parse(str)
if err != nil {
return nil, err
Expand Down
11 changes: 6 additions & 5 deletions google/location.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type Location struct {
client *storage.Service
}

// Service returns the Google Storage Service.
func (l *Location) Service() *storage.Service {
return l.client
}
Expand All @@ -28,10 +29,10 @@ func (l *Location) Close() error {
// CreateContainer creates a new container, in this case a bucket.
func (l *Location) CreateContainer(containerName string) (stow.Container, error) {

projId, _ := l.config.Config(ConfigProjectId)
projID, _ := l.config.Config(ConfigProjectID)
// Create a bucket.
_, err := l.client.Buckets.Insert(projId, &storage.Bucket{Name: containerName}).Do()
//res, err := l.client.Buckets.Insert(projId, &storage.Bucket{Name: containerName}).Do()
_, err := l.client.Buckets.Insert(projID, &storage.Bucket{Name: containerName}).Do()
//res, err := l.client.Buckets.Insert(projID, &storage.Bucket{Name: containerName}).Do()
if err != nil {
return nil, err
}
Expand All @@ -47,10 +48,10 @@ func (l *Location) CreateContainer(containerName string) (stow.Container, error)
// Containers returns a slice of the Container interface, a cursor, and an error.
func (l *Location) Containers(prefix string, cursor string, count int) ([]stow.Container, string, error) {

projId, _ := l.config.Config(ConfigProjectId)
projID, _ := l.config.Config(ConfigProjectID)

// List all objects in a bucket using pagination
call := l.client.Buckets.List(projId).MaxResults(int64(count))
call := l.client.Buckets.List(projID).MaxResults(int64(count))

if prefix != "" {
call.Prefix(prefix)
Expand Down
6 changes: 3 additions & 3 deletions google/stow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import (
func TestStow(t *testing.T) {

credFile := os.Getenv("GOOGLE_CREDENTIALS_FILE")
projectId := os.Getenv("GOOGLE_PROJECT_ID")
projectID := os.Getenv("GOOGLE_PROJECT_ID")

if credFile == "" || projectId == "" {
if credFile == "" || projectID == "" {
t.Skip("skipping test because GOOGLE_CREDENTIALS_FILE or GOOGLE_PROJECT_ID not set.")
}

Expand All @@ -27,7 +27,7 @@ func TestStow(t *testing.T) {

config := stow.ConfigMap{
"json": string(b),
"project_id": projectId,
"project_id": projectID,
}
test.All(t, "google", config)
}
Expand Down
6 changes: 3 additions & 3 deletions s3/stow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ import (
)

func TestStow(t *testing.T) {
accessKeyId := os.Getenv("S3ACCESSKEYID")
accessKeyID := os.Getenv("S3ACCESSKEYID")
secretKey := os.Getenv("S3SECRETKEY")
region := os.Getenv("S3REGION")

if accessKeyId == "" || secretKey == "" || region == "" {
if accessKeyID == "" || secretKey == "" || region == "" {
t.Skip("skipping test because missing one or more of S3ACCESSKEYID S3SECRETKEY S3REGION")
}

config := stow.ConfigMap{
"access_key_id": accessKeyId,
"access_key_id": accessKeyID,
"secret_key": secretKey,
"region": region,
}
Expand Down
2 changes: 1 addition & 1 deletion s3/v2signer.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,4 +231,4 @@ const logSignInfoMsg = `DEBUG: Request Signature:
func (v2 *signer) logSigningInfo() {
msg := fmt.Sprintf(logSignInfoMsg, v2.stringToSign, v2.signature)
v2.Logger.Log(msg)
}
}
6 changes: 3 additions & 3 deletions swift/stow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ func TestStow(t *testing.T) {
username := os.Getenv("SWIFTUSERNAME")
key := os.Getenv("SWIFTKEY")
tenantName := os.Getenv("SWIFTTENANTNAME")
tenantAuthUrl := os.Getenv("SWIFTTENANTAUTHURL")
tenantAuthURL := os.Getenv("SWIFTTENANTAUTHURL")

if username == "" || key == "" || tenantName == "" || tenantAuthUrl == "" {
if username == "" || key == "" || tenantName == "" || tenantAuthURL == "" {
t.Skip("skipping test because missing one or more of SWIFTUSERNAME SWIFTKEY SWIFTTENANTNAME SWIFTTENANTAUTHURL")
}

cfg := stow.ConfigMap{
"username": username,
"key": key,
"tenant_name": tenantName,
"tenant_auth_url": tenantAuthUrl,
"tenant_auth_url": tenantAuthURL,
//"tenant_id": "b04239c7467548678b4822e9dad96030",
}
test.All(t, "swift", cfg)
Expand Down