Skip to content

Commit bbdc57b

Browse files
committed
Merge branch 'master' of github.com:larrabee/s3sync
2 parents 7ef0522 + d175ed7 commit bbdc57b

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

cli/cli.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,15 @@ type connect struct {
4141
type args struct {
4242
// Source config
4343
Source string `arg:"positional"`
44+
SourceNoSign bool `arg:"--sn" help:"Don't sign request to source AWS for anonymous access"`
4445
SourceKey string `arg:"--sk" help:"Source AWS key"`
4546
SourceSecret string `arg:"--ss" help:"Source AWS session secret"`
4647
SourceToken string `arg:"--st" help:"Source AWS token"`
4748
SourceRegion string `arg:"--sr" help:"Source AWS Region"`
4849
SourceEndpoint string `arg:"--se" help:"Source AWS Endpoint"`
4950
// Target config
5051
Target string `arg:"positional"`
52+
TargetNoSign bool `arg:"--tn" help:"Don't sign request to target AWS for anonymous access"`
5153
TargetKey string `arg:"--tk" help:"Target AWS key"`
5254
TargetSecret string `arg:"--ts" help:"Target AWS secret"`
5355
TargetToken string `arg:"--tt" help:"Target AWS session token"`

cli/setup.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ func setupStorages(ctx context.Context, syncGroup *pipeline.Group, cli *argsPars
1515
var sourceStorage, targetStorage storage.Storage
1616
switch cli.Source.Type {
1717
case storage.TypeS3:
18-
sourceStorage = s3.NewS3Storage(cli.SourceKey, cli.SourceSecret, cli.SourceToken, cli.SourceRegion, cli.SourceEndpoint,
18+
sourceStorage = s3.NewS3Storage(cli.SourceNoSign, cli.SourceKey, cli.SourceSecret, cli.SourceToken, cli.SourceRegion, cli.SourceEndpoint,
1919
cli.Source.Bucket, cli.Source.Path, cli.S3KeysPerReq, cli.S3Retry, cli.S3RetryInterval,
2020
)
2121
case storage.TypeFS:
@@ -24,7 +24,7 @@ func setupStorages(ctx context.Context, syncGroup *pipeline.Group, cli *argsPars
2424

2525
switch cli.Target.Type {
2626
case storage.TypeS3:
27-
targetStorage = s3.NewS3Storage(cli.TargetKey, cli.TargetSecret, cli.TargetToken, cli.TargetRegion, cli.TargetEndpoint,
27+
targetStorage = s3.NewS3Storage(cli.TargetNoSign, cli.TargetKey, cli.TargetSecret, cli.TargetToken, cli.TargetRegion, cli.TargetEndpoint,
2828
cli.Target.Bucket, cli.Target.Path, cli.S3KeysPerReq, cli.S3Retry, cli.S3RetryInterval,
2929
)
3030
case storage.TypeFS:

storage/s3/s3.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,17 @@ type S3Storage struct {
3333
// NewS3Storage return new configured S3 storage.
3434
//
3535
// You should always create new storage with this constructor.
36-
func NewS3Storage(awsAccessKey, awsSecretKey, awsToken, awsRegion, endpoint, bucketName, prefix string, keysPerReq int64, retryCnt uint, retryDelay time.Duration) *S3Storage {
36+
func NewS3Storage(awsNoSign bool, awsAccessKey, awsSecretKey, awsToken, awsRegion, endpoint, bucketName, prefix string, keysPerReq int64, retryCnt uint, retryDelay time.Duration) *S3Storage {
3737
sess := session.Must(session.NewSessionWithOptions(session.Options{
3838
SharedConfigState: session.SharedConfigEnable,
3939
}))
4040
sess.Config.S3ForcePathStyle = aws.Bool(true)
4141
sess.Config.Region = aws.String(awsRegion)
4242
sess.Config.Retryer = &Retryer{RetryCnt: retryCnt, RetryDelay: retryDelay}
4343

44-
if awsAccessKey != "" || awsSecretKey != "" {
44+
if awsNoSign {
45+
sess.Config.Credentials = credentials.AnonymousCredentials
46+
} else if awsAccessKey != "" || awsSecretKey != "" {
4547
sess.Config.Credentials = credentials.NewStaticCredentials(awsAccessKey, awsSecretKey, awsToken)
4648
} else if _, err := sess.Config.Credentials.Get(); err != nil {
4749
storage.Log.Debugf("Failed to load credentials from default config")

0 commit comments

Comments
 (0)