Skip to content

Commit 116906c

Browse files
pa250194squaremo
authored andcommitted
Fixed spelling and capitalization
Signed-off-by: pa250194 <[email protected]>
1 parent 751243c commit 116906c

File tree

2 files changed

+19
-21
lines changed

2 files changed

+19
-21
lines changed

pkg/gcp/gcp.go

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ import (
2424
"os"
2525
"path/filepath"
2626

27-
gcpStorage "cloud.google.com/go/storage"
28-
interator "google.golang.org/api/iterator"
27+
gcpstorage "cloud.google.com/go/storage"
28+
"google.golang.org/api/iterator"
2929
"google.golang.org/api/option"
3030
)
3131

3232
var (
3333
// IteratorDone is returned when the looping of objects/content
3434
// has reached the end of the iteration.
35-
IteratorDone = interator.Done
35+
IteratorDone = iterator.Done
3636
// ErrorDirectoryExists is an error returned when the filename provided
3737
// is a directory.
3838
ErrorDirectoryExists = errors.New("filename is a directory")
@@ -44,15 +44,13 @@ var (
4444
type GCPClient struct {
4545
// client for interacting with the Google Cloud
4646
// Storage APIs.
47-
*gcpStorage.Client
47+
*gcpstorage.Client
4848
}
4949

50-
// NewClient creates a new GCP storage client
51-
// The Google Storage Client will automatically
52-
// look for the Google Application Credential environment variable
53-
// or look for the Google Application Credential file.
50+
// NewClient creates a new GCP storage client. The Client will automatically look for the Google Application
51+
// Credential environment variable or look for the Google Application Credential file.
5452
func NewClient(ctx context.Context, opts ...option.ClientOption) (*GCPClient, error) {
55-
client, err := gcpStorage.NewClient(ctx, opts...)
53+
client, err := gcpstorage.NewClient(ctx, opts...)
5654
if err != nil {
5755
return nil, err
5856
}
@@ -73,7 +71,7 @@ func ValidateSecret(secret map[string][]byte, name string) error {
7371
// BucketExists checks if the bucket with the provided name exists.
7472
func (c *GCPClient) BucketExists(ctx context.Context, bucketName string) (bool, error) {
7573
_, err := c.Client.Bucket(bucketName).Attrs(ctx)
76-
if err == gcpStorage.ErrBucketNotExist {
74+
if err == gcpstorage.ErrBucketNotExist {
7775
return false, err
7876
}
7977
if err != nil {
@@ -86,7 +84,7 @@ func (c *GCPClient) BucketExists(ctx context.Context, bucketName string) (bool,
8684
func (c *GCPClient) ObjectExists(ctx context.Context, bucketName, objectName string) (bool, error) {
8785
_, err := c.Client.Bucket(bucketName).Object(objectName).Attrs(ctx)
8886
// ErrObjectNotExist is returned if the object does not exist
89-
if err == gcpStorage.ErrObjectNotExist {
87+
if err == gcpstorage.ErrObjectNotExist {
9088
return false, err
9189
}
9290
if err != nil {
@@ -160,7 +158,7 @@ func (c *GCPClient) FGetObject(ctx context.Context, bucketName, objectName, loca
160158
// ListObjects lists the objects/contents of the bucket whose bucket name is provided.
161159
// the objects are returned as an Objectiterator and .Next() has to be called on them
162160
// to loop through the Objects.
163-
func (c *GCPClient) ListObjects(ctx context.Context, bucketName string, query *gcpStorage.Query) *gcpStorage.ObjectIterator {
161+
func (c *GCPClient) ListObjects(ctx context.Context, bucketName string, query *gcpstorage.Query) *gcpstorage.ObjectIterator {
164162
items := c.Client.Bucket(bucketName).Objects(ctx, query)
165163
return items
166164
}

pkg/gcp/gcp_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import (
3232
"testing"
3333
"time"
3434

35-
gcpStorage "cloud.google.com/go/storage"
35+
gcpstorage "cloud.google.com/go/storage"
3636
"github.com/fluxcd/source-controller/pkg/gcp"
3737
"google.golang.org/api/googleapi"
3838
raw "google.golang.org/api/storage/v1"
@@ -48,7 +48,7 @@ const (
4848

4949
var (
5050
hc *http.Client
51-
client *gcpStorage.Client
51+
client *gcpstorage.Client
5252
close func()
5353
err error
5454
)
@@ -101,7 +101,7 @@ func TestMain(m *testing.M) {
101101
}
102102
})
103103
ctx := context.Background()
104-
client, err = gcpStorage.NewClient(ctx, option.WithHTTPClient(hc))
104+
client, err = gcpstorage.NewClient(ctx, option.WithHTTPClient(hc))
105105
if err != nil {
106106
log.Fatal(err)
107107
}
@@ -131,7 +131,7 @@ func TestBucketNotExists(t *testing.T) {
131131
Client: client,
132132
}
133133
exists, err := gcpClient.BucketExists(context.Background(), bucket)
134-
assert.Error(t, err, gcpStorage.ErrBucketNotExist.Error())
134+
assert.Error(t, err, gcpstorage.ErrBucketNotExist.Error())
135135
assert.Assert(t, !exists)
136136
}
137137

@@ -140,7 +140,7 @@ func TestObjectExists(t *testing.T) {
140140
Client: client,
141141
}
142142
exists, err := gcpClient.ObjectExists(context.Background(), bucketName, objectName)
143-
if err == gcpStorage.ErrObjectNotExist {
143+
if err == gcpstorage.ErrObjectNotExist {
144144
assert.NilError(t, err)
145145
}
146146
assert.NilError(t, err)
@@ -153,23 +153,23 @@ func TestObjectNotExists(t *testing.T) {
153153
Client: client,
154154
}
155155
exists, err := gcpClient.ObjectExists(context.Background(), bucketName, object)
156-
assert.Error(t, err, gcpStorage.ErrObjectNotExist.Error())
156+
assert.Error(t, err, gcpstorage.ErrObjectNotExist.Error())
157157
assert.Assert(t, !exists)
158158
}
159159

160160
func TestListObjects(t *testing.T) {
161161
gcpClient := &gcp.GCPClient{
162162
Client: client,
163163
}
164-
objectInterator := gcpClient.ListObjects(context.Background(), bucketName, nil)
164+
objectIterator := gcpClient.ListObjects(context.Background(), bucketName, nil)
165165
for {
166-
_, err := objectInterator.Next()
166+
_, err := objectIterator.Next()
167167
if err == gcp.IteratorDone {
168168
break
169169
}
170170
assert.NilError(t, err)
171171
}
172-
assert.Assert(t, objectInterator != nil)
172+
assert.Assert(t, objectIterator != nil)
173173
}
174174

175175
func TestFGetObject(t *testing.T) {

0 commit comments

Comments
 (0)