-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.go
executable file
·40 lines (32 loc) · 1.07 KB
/
utils.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package s3fs
import (
"unicode"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/aws/aws-sdk-go/aws/session"
)
func isASCII(s string) bool {
for _, c := range s {
if c > unicode.MaxASCII {
return false
}
}
return true
}
// StringPtr converts string to string pointer.
func StringPtr(v string) *string {
return &v
}
// NewAWSSession returns a default AWS session.
func NewAWSSession() *session.Session {
return session.Must(session.NewSession())
}
// NewAWSConfigWithStaticCredentials returns AWS config with static credentials.
func NewAWSConfigWithStaticCredentials(awsAccessKey, awsSecretKey string) *aws.Config {
return aws.NewConfig().
WithCredentials(credentials.NewStaticCredentials(awsAccessKey, awsSecretKey, ""))
}
// NewAWSConfigWithStaticCredentialsAndRegion returns AWS config with static credentials and region.
func NewAWSConfigWithStaticCredentialsAndRegion(awsAccessKey, awsSecretKey, awsRegion string) *aws.Config {
return NewAWSConfigWithStaticCredentials(awsAccessKey, awsSecretKey).WithRegion(awsRegion)
}