forked from forgejo/forgejo
Add minio bucket lookup type option
This commit is contained in:
parent
c2f4fcca5a
commit
f4fd81b5d1
6 changed files with 74 additions and 8 deletions
|
@ -82,14 +82,26 @@ func NewMinioStorage(ctx context.Context, cfg *setting.Storage) (ObjectStorage,
|
|||
if config.ChecksumAlgorithm != "" && config.ChecksumAlgorithm != "default" && config.ChecksumAlgorithm != "md5" {
|
||||
return nil, fmt.Errorf("invalid minio checksum algorithm: %s", config.ChecksumAlgorithm)
|
||||
}
|
||||
var lookup minio.BucketLookupType
|
||||
switch config.BucketLookup {
|
||||
case "auto", "":
|
||||
lookup = minio.BucketLookupAuto
|
||||
case "dns":
|
||||
lookup = minio.BucketLookupDNS
|
||||
case "path":
|
||||
lookup = minio.BucketLookupPath
|
||||
default:
|
||||
return nil, fmt.Errorf("invalid minio bucket lookup type %s", config.BucketLookup)
|
||||
}
|
||||
|
||||
log.Info("Creating Minio storage at %s:%s with base path %s", config.Endpoint, config.Bucket, config.BasePath)
|
||||
|
||||
minioClient, err := minio.New(config.Endpoint, &minio.Options{
|
||||
Creds: credentials.NewStaticV4(config.AccessKeyID, config.SecretAccessKey, ""),
|
||||
Secure: config.UseSSL,
|
||||
Transport: &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: config.InsecureSkipVerify}},
|
||||
Region: config.Location,
|
||||
Creds: credentials.NewStaticV4(config.AccessKeyID, config.SecretAccessKey, ""),
|
||||
Secure: config.UseSSL,
|
||||
Transport: &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: config.InsecureSkipVerify}},
|
||||
Region: config.Location,
|
||||
BucketLookup: lookup,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, convertMinioErr(err)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue