File tree 2 files changed +11
-4
lines changed
2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -72,7 +72,6 @@ func isValidConfig(config Configs) bool {
72
72
valid = valid && config .WebConfigs .Port > 0
73
73
valid = valid && config .WebConfigs .Port < 65535
74
74
valid = valid && len (config .S3configs .BucketName ) > 0
75
- valid = valid && len (config .S3configs .CredentialsFile ) > 0
76
75
valid = valid && len (config .S3configs .Region ) > 0
77
76
return valid
78
77
}
Original file line number Diff line number Diff line change 1
1
package main
2
2
3
3
import (
4
+ "log"
5
+
4
6
"github.com/aws/aws-sdk-go/aws"
5
7
"github.com/aws/aws-sdk-go/aws/credentials"
6
8
"github.com/aws/aws-sdk-go/aws/session"
@@ -20,9 +22,15 @@ type S3configs struct {
20
22
// NewS3Fetcher is a S3 backed implementation of the FileFetcher interface.
21
23
// it does the setup of the S3 service session state required to implement FileFetcher interface
22
24
func NewS3Fetcher (cfg S3configs ) FileFetcher {
23
- svc := s3 .New (session .New (
24
- aws .NewConfig ().WithRegion (cfg .Region ).WithCredentials (
25
- credentials .NewSharedCredentials (cfg .CredentialsFile , "default" ))))
25
+ awsCfg := aws .NewConfig ().WithRegion (cfg .Region )
26
+ if cfg .CredentialsFile != "" {
27
+ log .Printf ("using AWS credentials from %s" , cfg .CredentialsFile )
28
+ awsCfg = awsCfg .WithCredentials (credentials .NewSharedCredentials (cfg .CredentialsFile , "default" ))
29
+ } else {
30
+ log .Print ("no AWS credentials file specified, using the default credentials chain" )
31
+ }
32
+
33
+ svc := s3 .New (session .New (awsCfg ))
26
34
cfg .s3svc = svc
27
35
28
36
return cfg
You can’t perform that action at this time.
0 commit comments