From 1420d717e3c79f849fc605813663ef8a0b5634fd Mon Sep 17 00:00:00 2001 From: Gani Georgiev Date: Thu, 6 Apr 2023 20:17:22 +0300 Subject: [PATCH] [#2231] revert the aws-sdk-go-v2 change --- .github/workflows/release.yaml | 2 +- CHANGELOG.md | 4 ++++ tools/filesystem/filesystem.go | 35 +++++++++++----------------------- 3 files changed, 16 insertions(+), 25 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index fb304ef8b..ed0ceace4 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -21,7 +21,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v3 with: - go-version: '>=1.20.0' + go-version: '>=1.20.3' # This step usually is not needed because the /ui/dist is pregenerated locally # but its here to ensure that each release embeds the latest admin ui artifacts. diff --git a/CHANGELOG.md b/CHANGELOG.md index d27a3966b..b55c2c6c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ - Fixed Admin UI Logs `meta` visualization in Firefox ([#2221](https://github.com/pocketbase/pocketbase/issues/2221)). +- Downgraded to v1 of the `aws/aws-sdk-go` package since v2 has compatibility issues with GCS ([#2231](https://github.com/pocketbase/pocketbase/issues/2231)). + +- Upgraded the GitHub action to use [min Go 1.20.3](https://github.com/golang/go/issues?q=milestone%3AGo1.20.3+label%3ACherryPickApproved) for the prebuilt executable since it contains some minor `net/http` security fixes. + ## v0.14.2 diff --git a/tools/filesystem/filesystem.go b/tools/filesystem/filesystem.go index 740d2a31d..8abbe7573 100644 --- a/tools/filesystem/filesystem.go +++ b/tools/filesystem/filesystem.go @@ -14,10 +14,9 @@ import ( "strconv" "strings" - "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/config" - "github.com/aws/aws-sdk-go-v2/credentials" - "github.com/aws/aws-sdk-go-v2/service/s3" + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/credentials" + "github.com/aws/aws-sdk-go/aws/session" "github.com/disintegration/imaging" "github.com/gabriel-vasile/mimetype" "github.com/pocketbase/pocketbase/tools/list" @@ -44,31 +43,19 @@ func NewS3( ) (*System, error) { ctx := context.Background() // default context - cred := credentials.NewStaticCredentialsProvider(accessKey, secretKey, "") - - cfg, err := config.LoadDefaultConfig(ctx, - config.WithCredentialsProvider(cred), - config.WithRegion(region), - config.WithEndpointResolverWithOptions(aws.EndpointResolverWithOptionsFunc(func(service, region string, options ...interface{}) (aws.Endpoint, error) { - // ensure that the endpoint has url scheme for - // backward compatibility with v1 of the aws sdk - prefixedEndpoint := endpoint - if !strings.Contains(endpoint, "://") { - prefixedEndpoint = "https://" + endpoint - } + cred := credentials.NewStaticCredentials(accessKey, secretKey, "") - return aws.Endpoint{URL: prefixedEndpoint, SigningRegion: region}, nil - })), - ) + sess, err := session.NewSession(&aws.Config{ + Region: aws.String(region), + Endpoint: aws.String(endpoint), + Credentials: cred, + S3ForcePathStyle: aws.Bool(s3ForcePathStyle), + }) if err != nil { return nil, err } - client := s3.NewFromConfig(cfg, func(o *s3.Options) { - o.UsePathStyle = s3ForcePathStyle - }) - - bucket, err := s3blob.OpenBucketV2(ctx, client, bucketName, nil) + bucket, err := s3blob.OpenBucket(ctx, sess, bucketName, nil) if err != nil { return nil, err }