From 3e6b405eaece1640fd19a9a6233b48d0ff7e65a5 Mon Sep 17 00:00:00 2001 From: ali abdalla Date: Sat, 1 Feb 2025 06:29:01 +0100 Subject: [PATCH] configure s3 to support minio --- cmd/extension-installer/main.go | 15 +++++++++------ percona/extensions/s3.go | 14 +++++++++++--- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/cmd/extension-installer/main.go b/cmd/extension-installer/main.go index 5045e608eb..3ee86c6138 100644 --- a/cmd/extension-installer/main.go +++ b/cmd/extension-installer/main.go @@ -11,27 +11,30 @@ import ( ) func main() { - var storageType, endpoint, region, bucket, key, extensionPath string - var install, uninstall bool + var storageType, endpoint, region, bucket, key, extensionPath, uriStyle string + var install, uninstall, verifyTLS bool flag.StringVar(&storageType, "type", "", "Storage type") flag.StringVar(&endpoint, "endpoint", "", "Storage endpoint") flag.StringVar(®ion, "region", "", "Storage region") flag.StringVar(&bucket, "bucket", "", "Storage bucket") flag.StringVar(&extensionPath, "extension-path", "", "Extension installation path") + flag.StringVar(&uriStyle, "uri-style", "url", "URI style, either path or url") + flag.StringVar(&key, "key", "", "Extension archive key") flag.BoolVar(&install, "install", false, "Install extension") flag.BoolVar(&uninstall, "uninstall", false, "Uninstall extension") + flag.BoolVar(&verifyTLS, "verify-tls", true, "Verify TLS") flag.Parse() if (install && uninstall) || (!install && !uninstall) { log.Fatalf("ERROR: set either -install or -uninstall") } - log.Printf("starting extension installer for %s/%s (%s) in %s", bucket, key, storageType, region) + log.Printf("starting extension installer for %s/%s (%s) in %s", bucket, key, storageType, region, uriStyle, verifyTLS) - storage := initStorage(extensions.StorageType(storageType), endpoint, bucket, region) + storage := initStorage(extensions.StorageType(storageType), endpoint, bucket, region, uriStyle, verifyTLS) packageName := key + ".tar.gz" @@ -70,10 +73,10 @@ func main() { } } -func initStorage(storageType extensions.StorageType, endpoint, bucket, region string) extensions.ObjectGetter { +func initStorage(storageType extensions.StorageType, endpoint, bucket, region string, uriStyle string, verifyTLS bool) extensions.ObjectGetter { switch storageType { case extensions.StorageTypeS3: - return extensions.NewS3(endpoint, region, bucket) + return extensions.NewS3(endpoint, region, bucket, uriStyle, verifyTLS) default: log.Fatalf("unknown storage type: %s", os.Getenv("STORAGE_TYPE")) } diff --git a/percona/extensions/s3.go b/percona/extensions/s3.go index 0106a7f393..a24c9b1e62 100644 --- a/percona/extensions/s3.go +++ b/percona/extensions/s3.go @@ -11,13 +11,19 @@ import ( type S3 struct { Region string Bucket string - + uriStyle string + verifyTLS bool svc *s3.S3 } -func NewS3(endpoint, region, bucket string) *S3 { +func NewS3(endpoint, region, bucket string, uriStyle string, verifyTLS bool) *S3 { cfg := aws.NewConfig().WithRegion(region) - + if(uriStyle == "path") { + cfg = cfg.WithS3ForcePathStyle(true) + } + if !verifyTLS { + cfg = cfg.WithDisableSSL(true) + } if endpoint != "" { cfg = cfg.WithEndpoint(endpoint) } @@ -28,6 +34,8 @@ func NewS3(endpoint, region, bucket string) *S3 { return &S3{ Region: region, Bucket: bucket, + uriStyle: uriStyle, + verifyTLS: verifyTLS, svc: svc, } }