From f386eacfd606f0f1a8e72202be162c09516ecbac Mon Sep 17 00:00:00 2001 From: Timothy Lau Date: Sun, 10 Nov 2024 00:53:07 +0800 Subject: [PATCH 1/3] feat: add s3ForcePathStyle option for s3 publisher --- pkg/publisher/s3.go | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/pkg/publisher/s3.go b/pkg/publisher/s3.go index 2ea0aee..79b7630 100644 --- a/pkg/publisher/s3.go +++ b/pkg/publisher/s3.go @@ -22,10 +22,11 @@ import ( type ObjectOptions struct { file *string - endpoint *string - region *string - bucket *string - key *string + forcePathStyle *bool + endpoint *string + region *string + bucket *string + key *string acl *string storageClass *string @@ -40,10 +41,11 @@ func ConfigurePublishToS3Command(app *kingpin.Application) { options := ObjectOptions{ file: command.Flag("file", "").Required().String(), - region: command.Flag("region", "").String(), - bucket: command.Flag("bucket", "").Required().String(), - key: command.Flag("key", "").Required().String(), - endpoint: command.Flag("endpoint", "").String(), + forcePathStyle: command.Flag("forcePathStyle", "").Default("true").Bool(), + region: command.Flag("region", "").String(), + bucket: command.Flag("bucket", "").Required().String(), + key: command.Flag("key", "").Required().String(), + endpoint: command.Flag("endpoint", "").String(), acl: command.Flag("acl", "").String(), storageClass: command.Flag("storageClass", "").String(), @@ -112,6 +114,11 @@ func upload(options *ObjectOptions) error { } if *options.endpoint != "" { awsConfig.Endpoint = options.endpoint + } + + if options.forcePathStyle != nil { + awsConfig.S3ForcePathStyle = aws.Bool(options.forcePathStyle) + } else { awsConfig.S3ForcePathStyle = aws.Bool(true) } From 5c863d1d4f8ad7f8762cc5023e49bbc6983b773c Mon Sep 17 00:00:00 2001 From: Timothy Lau Date: Sun, 10 Nov 2024 01:07:38 +0800 Subject: [PATCH 2/3] chore: add changeset --- .changeset/healthy-flies-rescue.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/healthy-flies-rescue.md diff --git a/.changeset/healthy-flies-rescue.md b/.changeset/healthy-flies-rescue.md new file mode 100644 index 0000000..cd4264b --- /dev/null +++ b/.changeset/healthy-flies-rescue.md @@ -0,0 +1,5 @@ +--- +"app-builder-bin": minor +--- + +feat: add s3ForcePathStyle option for s3 publisher From 89f1645eb1e29e43cbe947bf88b1a9c8bec964bb Mon Sep 17 00:00:00 2001 From: Timothy Lau Date: Wed, 13 Nov 2024 00:38:59 +0800 Subject: [PATCH 3/3] fix: simplify S3 forcePathStyle configuration in upload function --- pkg/publisher/s3.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/pkg/publisher/s3.go b/pkg/publisher/s3.go index 79b7630..835f844 100644 --- a/pkg/publisher/s3.go +++ b/pkg/publisher/s3.go @@ -114,12 +114,7 @@ func upload(options *ObjectOptions) error { } if *options.endpoint != "" { awsConfig.Endpoint = options.endpoint - } - - if options.forcePathStyle != nil { - awsConfig.S3ForcePathStyle = aws.Bool(options.forcePathStyle) - } else { - awsConfig.S3ForcePathStyle = aws.Bool(true) + awsConfig.S3ForcePathStyle = aws.Bool(*options.forcePathStyle) } //awsConfig.WithLogLevel(aws.LogDebugWithHTTPBody)