Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

K8SPG-728: Configure s3 to support minio for extensions #1034

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions cmd/extension-installer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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"))
}
Expand Down
14 changes: 11 additions & 3 deletions percona/extensions/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if(uriStyle == "path") {
if uriStyle == "path" {

cfg = cfg.WithS3ForcePathStyle(true)
}
if !verifyTLS {
cfg = cfg.WithDisableSSL(true)
}
if endpoint != "" {
cfg = cfg.WithEndpoint(endpoint)
}
Expand All @@ -28,6 +34,8 @@ func NewS3(endpoint, region, bucket string) *S3 {
return &S3{
Region: region,
Bucket: bucket,
uriStyle: uriStyle,
verifyTLS: verifyTLS,
svc: svc,
}
}
Expand Down