Skip to content

Commit 8f1101b

Browse files
authored
Merge pull request #330 from midnightconman/jcampbell/s3creds-20241122
Export providers.S3Credentials
2 parents ec19f24 + a0f34f5 commit 8f1101b

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

pkg/io/providers/aws.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ import (
3434
const S3MinUploadPartSize = 5 * 1024 * 1024 // 5 MiB
3535

3636
// getS3Bucket opens a gocloud blob.Bucket based on given credentials in the format the
37-
// struct s3Credentials defines (see documentation of GetBucket for an example)
37+
// struct S3Credentials defines (see documentation of GetBucket for an example)
3838
func getS3Bucket(ctx context.Context, creds []byte, bucketName string) (*blob.Bucket, error) {
39-
s3Creds := &s3Credentials{}
39+
s3Creds := &S3Credentials{}
4040
if err := json.Unmarshal(creds, s3Creds); err != nil {
4141
return nil, fmt.Errorf("error getting S3 credentials from JSON: %w", err)
4242
}
@@ -51,7 +51,7 @@ func getS3Bucket(ctx context.Context, creds []byte, bucketName string) (*blob.Bu
5151
return bkt, nil
5252
}
5353

54-
func newS3Client(ctx context.Context, creds *s3Credentials) (*s3.Client, error) {
54+
func newS3Client(ctx context.Context, creds *S3Credentials) (*s3.Client, error) {
5555
var opts []func(*config.LoadOptions) error
5656

5757
// Use the default credential chain if no credentials are specified

pkg/io/providers/aws_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,28 +29,28 @@ import (
2929
func Test_newS3Client(t *testing.T) {
3030
tests := []struct {
3131
name string
32-
creds s3Credentials
33-
want s3Credentials
32+
creds S3Credentials
33+
want S3Credentials
3434
}{
3535
{
3636
name: "only accesskey and secretkey set",
37-
creds: s3Credentials{
37+
creds: S3Credentials{
3838
AccessKey: "foo",
3939
SecretKey: "bar",
4040
},
41-
want: s3Credentials{},
41+
want: S3Credentials{},
4242
},
4343
{
4444
name: "all options set ",
45-
creds: s3Credentials{
45+
creds: S3Credentials{
4646
AccessKey: "foo",
4747
SecretKey: "bar",
4848
Endpoint: "https://foobar.com",
4949
Region: "eu01",
5050
Insecure: true,
5151
S3ForcePathStyle: true,
5252
},
53-
want: s3Credentials{
53+
want: S3Credentials{
5454
Endpoint: "https://foobar.com",
5555
Region: "eu01",
5656
Insecure: true,
@@ -94,7 +94,7 @@ func Test_newS3Client(t *testing.T) {
9494
} else {
9595
endpoint = *s3opts.BaseEndpoint
9696
}
97-
got := s3Credentials{
97+
got := S3Credentials{
9898
Region: s3opts.Region,
9999
Endpoint: endpoint,
100100
S3ForcePathStyle: s3opts.UsePathStyle,

pkg/io/providers/providers.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,13 @@ func DisplayName(provider string) string {
7272
// "access_key": "access_key",
7373
// "secret_key": "secret_key"
7474
// }
75-
func GetBucket(ctx context.Context, s3Credentials []byte, path string) (*blob.Bucket, error) {
75+
func GetBucket(ctx context.Context, S3Credentials []byte, path string) (*blob.Bucket, error) {
7676
storageProvider, bucket, _, err := ParseStoragePath(path)
7777
if err != nil {
7878
return nil, err
7979
}
80-
if storageProvider == S3 && len(s3Credentials) > 0 {
81-
return getS3Bucket(ctx, s3Credentials, bucket)
80+
if storageProvider == S3 && len(S3Credentials) > 0 {
81+
return getS3Bucket(ctx, S3Credentials, bucket)
8282
}
8383

8484
bkt, err := blob.OpenBucket(ctx, fmt.Sprintf("%s://%s", storageProvider, bucket))
@@ -88,10 +88,10 @@ func GetBucket(ctx context.Context, s3Credentials []byte, path string) (*blob.Bu
8888
return bkt, nil
8989
}
9090

91-
// s3Credentials are credentials used to access S3 or an S3-compatible storage service
91+
// S3Credentials are credentials used to access S3 or an S3-compatible storage service
9292
// Endpoint is an optional property. Default is the AWS S3 endpoint. If set, the specified
9393
// endpoint will be used instead.
94-
type s3Credentials struct {
94+
type S3Credentials struct {
9595
Region string `json:"region"`
9696
Endpoint string `json:"endpoint"`
9797
Insecure bool `json:"insecure"`

0 commit comments

Comments
 (0)