mirror of
https://codeberg.org/git-pages/git-pages.git
synced 2026-07-21 00:42:20 +00:00
backend: s3: add option to choose bucket lookup type.
Certain S3 compatible storage providers does not support path style bucket lookup anymore, add config option to manually specify DNS style for minio. Signed-off-by: imi415 <imi415@imi.moe>
This commit is contained in:
@@ -14,6 +14,9 @@ type = 'fs'
|
||||
[storage.fs]
|
||||
root = './data'
|
||||
|
||||
[storage.s3]
|
||||
bucket-lookup = "auto"
|
||||
|
||||
[limits]
|
||||
max-site-size = '128MB'
|
||||
max-manifest-size = '1MB'
|
||||
|
||||
@@ -30,6 +30,7 @@ root = "./data"
|
||||
|
||||
[storage.s3] # non-default section
|
||||
endpoint = "play.min.io"
|
||||
bucket-lookup = "auto"
|
||||
access-key-id = "Q3AM3UQ867SPQQA43P2F"
|
||||
secret-access-key = "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG"
|
||||
region = "us-east-1"
|
||||
|
||||
+15
-1
@@ -155,13 +155,27 @@ func makeCacheOptions[K comparable, V any](
|
||||
}
|
||||
|
||||
func NewS3Backend(ctx context.Context, config *S3Config) (*S3Backend, error) {
|
||||
var bucketLookup minio.BucketLookupType
|
||||
|
||||
switch config.BucketLookup {
|
||||
case "auto":
|
||||
bucketLookup = minio.BucketLookupAuto
|
||||
case "path":
|
||||
bucketLookup = minio.BucketLookupPath
|
||||
case "dns":
|
||||
bucketLookup = minio.BucketLookupDNS
|
||||
default:
|
||||
return nil, fmt.Errorf("unknown bucket lookup type: %s", config.BucketLookup)
|
||||
}
|
||||
|
||||
client, err := minio.New(config.Endpoint, &minio.Options{
|
||||
Creds: credentials.NewStaticV4(
|
||||
config.AccessKeyID,
|
||||
config.SecretAccessKey,
|
||||
"",
|
||||
),
|
||||
Secure: !config.Insecure,
|
||||
Secure: !config.Insecure,
|
||||
BucketLookup: bucketLookup,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -112,6 +112,7 @@ type FSConfig struct {
|
||||
type S3Config struct {
|
||||
Endpoint string `toml:"endpoint"`
|
||||
Insecure bool `toml:"insecure"`
|
||||
BucketLookup string `toml:"bucket-lookup" default:"auto"`
|
||||
AccessKeyID string `toml:"access-key-id"`
|
||||
SecretAccessKey string `toml:"secret-access-key"`
|
||||
Region string `toml:"region"`
|
||||
|
||||
Reference in New Issue
Block a user