diff options
| author | 2022-11-22 13:28:55 +0000 | |
|---|---|---|
| committer | 2022-11-22 14:28:55 +0100 | |
| commit | a898160b0c8591be9677c158fa32d6a78d679152 (patch) | |
| tree | da8eb8324ec12374200aa9e5d7d25c3296a6b4da /testrig | |
| parent | [docs] Document non-buildx cross compilation for docker image (#1115) (diff) | |
| download | gotosocial-a898160b0c8591be9677c158fa32d6a78d679152.tar.xz | |
[chore] use kv.KVStore also for S3 storage (#1113)
* replace s3 storage implementation to also use kv.KVStore
Signed-off-by: kim <grufwub@gmail.com>
* pull in latest `go-store` fix
Signed-off-by: kim <grufwub@gmail.com>
* pull-in go-store v2.0.9 fixes, update s3 put chunk size to 5MiB
Signed-off-by: kim <grufwub@gmail.com>
Signed-off-by: kim <grufwub@gmail.com>
Diffstat (limited to 'testrig')
| -rw-r--r-- | testrig/storage.go | 32 | 
1 files changed, 27 insertions, 5 deletions
| diff --git a/testrig/storage.go b/testrig/storage.go index 657c81161..e29c82532 100644 --- a/testrig/storage.go +++ b/testrig/storage.go @@ -28,6 +28,7 @@ import (  	"codeberg.org/gruf/go-store/v2/storage"  	"github.com/minio/minio-go/v7"  	"github.com/minio/minio-go/v7/pkg/credentials" +	"github.com/superseriousbusiness/gotosocial/internal/config"  	gtsstorage "github.com/superseriousbusiness/gotosocial/internal/storage"  ) @@ -41,14 +42,35 @@ func NewInMemoryStorage() *gtsstorage.Local {  }  func NewS3Storage() gtsstorage.Driver { -	mc, err := minio.New(os.Getenv("GTS_STORAGE_S3_ENDPOINT"), &minio.Options{ -		Creds:  credentials.NewStaticV4(os.Getenv("GTS_STORAGE_S3_ACCESS_KEY"), os.Getenv("GTS_STORAGE_S3_SECRET_KEY"), ""), -		Secure: false, +	endpoint := config.GetStorageS3Endpoint() +	access := config.GetStorageS3AccessKey() +	secret := config.GetStorageS3SecretKey() +	secure := config.GetStorageS3UseSSL() +	bucket := config.GetStorageS3BucketName() +	proxy := config.GetStorageS3Proxy() + +	s3, err := storage.OpenS3(endpoint, bucket, &storage.S3Config{ +		CoreOpts: minio.Options{ +			Creds:  credentials.NewStaticV4(access, secret, ""), +			Secure: secure, +		}, +		GetOpts:      minio.GetObjectOptions{}, +		PutOpts:      minio.PutObjectOptions{}, +		PutChunkSize: 5 * 1024 * 1024, // 2MiB +		StatOpts:     minio.StatObjectOptions{}, +		RemoveOpts:   minio.RemoveObjectOptions{}, +		ListSize:     200,  	})  	if err != nil { -		panic(err) +		panic(fmt.Errorf("error opening s3 storage: %w", err)) +	} + +	return >sstorage.S3{ +		Proxy:   proxy, +		Bucket:  bucket, +		Storage: s3, +		KVStore: kv.New(s3),  	} -	return gtsstorage.NewS3(mc, os.Getenv("GTS_STORAGE_S3_BUCKET"), false)  }  // StandardStorageSetup populates the storage with standard test entries from the given directory. | 
