Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
configure s3 to support minio
Browse files Browse the repository at this point in the history
ali3bdalla committed Feb 1, 2025
1 parent fdd16c1 commit 3e6b405
Showing 2 changed files with 20 additions and 9 deletions.
15 changes: 9 additions & 6 deletions cmd/extension-installer/main.go
Original file line number Diff line number Diff line change
@@ -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(&region, "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"))
}
14 changes: 11 additions & 3 deletions percona/extensions/s3.go
Original file line number Diff line number Diff line change
@@ -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,
}
}

0 comments on commit 3e6b405

Please sign in to comment.