Skip to content

Commit 9bb3420

Browse files
committed
extended env AWS_CREDENTIALS support
1 parent 308b597 commit 9bb3420

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

s3/auth.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import (
1010
"github.com/viant/afs/storage"
1111
"io/ioutil"
1212
"os"
13+
"path"
14+
"strings"
1315
)
1416

1517
//AwsConfigProvider represents aws config provider
@@ -45,7 +47,11 @@ func NewAuthConfig(options ...storage.Option) (*AuthConfig, error) {
4547
return nil, errors.New("auth location was empty")
4648
}
4749
if location.Path != "" {
48-
file, err := os.Open(location.Path)
50+
locationPath := location.Path
51+
if strings.HasPrefix(locationPath, "~/") {
52+
locationPath = path.Join(os.Getenv("HOME"), locationPath[2:])
53+
}
54+
file, err := os.Open(locationPath)
4955
if err != nil {
5056
return nil, errors.Wrap(err, "failed to open auth config")
5157
}

s3/storager.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/viant/afs/storage"
1010
"github.com/viant/afs/url"
1111
"github.com/viant/afsc/logger"
12+
"log"
1213
"os"
1314
)
1415

@@ -52,6 +53,9 @@ func filterAuthOption(options []storage.Option) (*aws.Config, error) {
5253
}
5354
if credLocation := os.Getenv(awsCredentials); credLocation != "" {
5455
authConfig, err := NewAuthConfig(&option.Location{Path: credLocation})
56+
if err != nil {
57+
log.Print(err)
58+
}
5559
if err == nil {
5660
return authConfig.AwsConfig()
5761
}

0 commit comments

Comments
 (0)