From 9fdc34b5a5f3090e7c54d06011388bfd169ffed9 Mon Sep 17 00:00:00 2001 From: dicarne Date: Mon, 13 May 2024 03:08:44 +0000 Subject: [PATCH 01/12] Support minio virtual host pathlike --- modules/setting/storage.go | 1 + modules/storage/minio.go | 13 +++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/modules/setting/storage.go b/modules/setting/storage.go index 0bd52acc0f40c..a6ac30bd464ed 100644 --- a/modules/setting/storage.go +++ b/modules/setting/storage.go @@ -47,6 +47,7 @@ type MinioStorageConfig struct { InsecureSkipVerify bool `ini:"MINIO_INSECURE_SKIP_VERIFY"` ChecksumAlgorithm string `ini:"MINIO_CHECKSUM_ALGORITHM" json:",omitempty"` ServeDirect bool `ini:"SERVE_DIRECT"` + VirtualHost bool `ini:"VIRTUAL_HOST"` } // Storage represents configuration of storages diff --git a/modules/storage/minio.go b/modules/storage/minio.go index b58ab67dc747a..56e279ec97bcd 100644 --- a/modules/storage/minio.go +++ b/modules/storage/minio.go @@ -85,11 +85,16 @@ func NewMinioStorage(ctx context.Context, cfg *setting.Storage) (ObjectStorage, log.Info("Creating Minio storage at %s:%s with base path %s", config.Endpoint, config.Bucket, config.BasePath) + lookup := minio.BucketLookupPath + if config.VirtualHost { + lookup = minio.BucketLookupDNS + } 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) From fb80fa57412dde7384aeae6f0f5724b4f1c1d6d0 Mon Sep 17 00:00:00 2001 From: dicarne Date: Tue, 14 May 2024 12:53:04 +0800 Subject: [PATCH 02/12] Modify the default lookup method to be the same as before --- modules/storage/minio.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/storage/minio.go b/modules/storage/minio.go index 56e279ec97bcd..afaf8d2c50a18 100644 --- a/modules/storage/minio.go +++ b/modules/storage/minio.go @@ -85,7 +85,7 @@ func NewMinioStorage(ctx context.Context, cfg *setting.Storage) (ObjectStorage, log.Info("Creating Minio storage at %s:%s with base path %s", config.Endpoint, config.Bucket, config.BasePath) - lookup := minio.BucketLookupPath + lookup := minio.BucketLookupAuto if config.VirtualHost { lookup = minio.BucketLookupDNS } From 575644618a4c70c0a364c9dcad94014d790c71ed Mon Sep 17 00:00:00 2001 From: dicarne Date: Tue, 14 May 2024 13:11:23 +0800 Subject: [PATCH 03/12] fix incorrect fmt --- modules/setting/storage.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/setting/storage.go b/modules/setting/storage.go index a6ac30bd464ed..57188218fdc33 100644 --- a/modules/setting/storage.go +++ b/modules/setting/storage.go @@ -47,7 +47,7 @@ type MinioStorageConfig struct { InsecureSkipVerify bool `ini:"MINIO_INSECURE_SKIP_VERIFY"` ChecksumAlgorithm string `ini:"MINIO_CHECKSUM_ALGORITHM" json:",omitempty"` ServeDirect bool `ini:"SERVE_DIRECT"` - VirtualHost bool `ini:"VIRTUAL_HOST"` + VirtualHost bool `ini:"VIRTUAL_HOST"` } // Storage represents configuration of storages From 697982a2800557ed5d67cfa7895f407dc7568dd9 Mon Sep 17 00:00:00 2001 From: dicarne Date: Tue, 14 May 2024 14:13:04 +0800 Subject: [PATCH 04/12] Add `VIRTUAL_HOST` to document and app.example.ini. --- custom/conf/app.example.ini | 6 ++++++ docs/content/administration/config-cheat-sheet.en-us.md | 8 ++++++++ docs/content/administration/config-cheat-sheet.zh-cn.md | 8 ++++++++ 3 files changed, 22 insertions(+) diff --git a/custom/conf/app.example.ini b/custom/conf/app.example.ini index 577479e39fd24..eb201745c4662 100644 --- a/custom/conf/app.example.ini +++ b/custom/conf/app.example.ini @@ -1895,6 +1895,9 @@ LEVEL = Info ;; ;; Minio checksum algorithm: default (for MinIO or AWS S3) or md5 (for Cloudflare or Backblaze) ;MINIO_CHECKSUM_ALGORITHM = default +;; +;; Minio use virtual host style instead of path style when STORAGE_TYPE is `minio` +;VIRTUAL_HOST = false ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -2576,6 +2579,9 @@ LEVEL = Info ;; ;; Minio skip SSL verification available when STORAGE_TYPE is `minio` ;MINIO_INSECURE_SKIP_VERIFY = false +;; +;; Minio use virtual host style instead of path style when STORAGE_TYPE is `minio` +;VIRTUAL_HOST = false ;[proxy] ;; Enable the proxy, all requests to external via HTTP will be affected diff --git a/docs/content/administration/config-cheat-sheet.en-us.md b/docs/content/administration/config-cheat-sheet.en-us.md index 07712c1110a83..0d1338b8afbe2 100644 --- a/docs/content/administration/config-cheat-sheet.en-us.md +++ b/docs/content/administration/config-cheat-sheet.en-us.md @@ -851,6 +851,7 @@ Default templates for project boards: - `MINIO_USE_SSL`: **false**: Minio enabled ssl only available when STORAGE_TYPE is `minio` - `MINIO_INSECURE_SKIP_VERIFY`: **false**: Minio skip SSL verification available when STORAGE_TYPE is `minio` - `MINIO_CHECKSUM_ALGORITHM`: **default**: Minio checksum algorithm: `default` (for MinIO or AWS S3) or `md5` (for Cloudflare or Backblaze) +- `VIRTUAL_HOST`: **false**: Minio use virtual host style instead of path style when STORAGE_TYPE is `minio` ## Log (`log`) @@ -1272,6 +1273,7 @@ is `data/lfs` and the default of `MINIO_BASE_PATH` is `lfs/`. - `MINIO_BASE_PATH`: **lfs/**: Minio base path on the bucket only available when `STORAGE_TYPE` is `minio` - `MINIO_USE_SSL`: **false**: Minio enabled ssl only available when `STORAGE_TYPE` is `minio` - `MINIO_INSECURE_SKIP_VERIFY`: **false**: Minio skip SSL verification available when STORAGE_TYPE is `minio` +- `VIRTUAL_HOST`: **false**: Minio use virtual host style instead of path style when STORAGE_TYPE is `minio` ## Storage (`storage`) @@ -1286,6 +1288,7 @@ Default storage configuration for attachments, lfs, avatars, repo-avatars, repo- - `MINIO_LOCATION`: **us-east-1**: Minio location to create bucket only available when `STORAGE_TYPE` is `minio` - `MINIO_USE_SSL`: **false**: Minio enabled ssl only available when `STORAGE_TYPE` is `minio` - `MINIO_INSECURE_SKIP_VERIFY`: **false**: Minio skip SSL verification available when STORAGE_TYPE is `minio` +- `VIRTUAL_HOST`: **false**: Minio use virtual host style instead of path style when STORAGE_TYPE is `minio` The recommended storage configuration for minio like below: @@ -1307,6 +1310,8 @@ MINIO_USE_SSL = false ; Minio skip SSL verification available when STORAGE_TYPE is `minio` MINIO_INSECURE_SKIP_VERIFY = false SERVE_DIRECT = true +; Minio use virtual host style instead of path style when STORAGE_TYPE is `minio` +VIRTUAL_HOST = false ``` Defaultly every storage has their default base path like below @@ -1353,6 +1358,8 @@ MINIO_LOCATION = us-east-1 MINIO_USE_SSL = false ; Minio skip SSL verification available when STORAGE_TYPE is `minio` MINIO_INSECURE_SKIP_VERIFY = false +; Minio use virtual host style instead of path style when STORAGE_TYPE is `minio` +VIRTUAL_HOST = false ``` ## Repository Archive Storage (`storage.repo-archive`) @@ -1372,6 +1379,7 @@ is `data/repo-archive` and the default of `MINIO_BASE_PATH` is `repo-archive/`. - `MINIO_BASE_PATH`: **repo-archive/**: Minio base path on the bucket only available when `STORAGE_TYPE` is `minio` - `MINIO_USE_SSL`: **false**: Minio enabled ssl only available when `STORAGE_TYPE` is `minio` - `MINIO_INSECURE_SKIP_VERIFY`: **false**: Minio skip SSL verification available when STORAGE_TYPE is `minio` +- `VIRTUAL_HOST`: **false**: Minio use virtual host style instead of path style when STORAGE_TYPE is `minio` ## Repository Archives (`repo-archive`) diff --git a/docs/content/administration/config-cheat-sheet.zh-cn.md b/docs/content/administration/config-cheat-sheet.zh-cn.md index 3bb31d3d711cf..313933acded01 100644 --- a/docs/content/administration/config-cheat-sheet.zh-cn.md +++ b/docs/content/administration/config-cheat-sheet.zh-cn.md @@ -796,6 +796,7 @@ Gitea 创建以下非唯一队列: - `MINIO_USE_SSL`: **false**: Minio 启用 SSL,仅当 STORAGE_TYPE 为 `minio` 时可用。 - `MINIO_INSECURE_SKIP_VERIFY`: **false**: Minio 跳过 SSL 验证,仅当 STORAGE_TYPE 为 `minio` 时可用。 - `MINIO_CHECKSUM_ALGORITHM`: **default**: Minio 校验算法:`default`(适用于 MinIO 或 AWS S3)或 `md5`(适用于 Cloudflare 或 Backblaze) +- `VIRTUAL_HOST`: **false**: Minio 使用虚拟托管样式而不是路径样式,仅当 STORAGE_TYPE 为 `minio` 时可用。 ## 日志 (`log`) @@ -1201,6 +1202,7 @@ ALLOW_DATA_URI_IMAGES = true - `MINIO_BASE_PATH`:**lfs/**:桶上的 Minio 基本路径,仅在 `STORAGE_TYPE` 为 `minio` 时可用。 - `MINIO_USE_SSL`:**false**:Minio 启用 ssl,仅在 `STORAGE_TYPE` 为 `minio` 时可用。 - `MINIO_INSECURE_SKIP_VERIFY`:**false**:Minio 跳过 SSL 验证,仅在 `STORAGE_TYPE` 为 `minio` 时可用。 +- `VIRTUAL_HOST`: **false**: Minio 使用虚拟托管样式而不是路径样式,仅当 STORAGE_TYPE 为 `minio` 时可用。 ## 存储 (`storage`) @@ -1215,6 +1217,7 @@ ALLOW_DATA_URI_IMAGES = true - `MINIO_LOCATION`:**us-east-1**:创建桶的 Minio 位置,仅在 `STORAGE_TYPE` 为 `minio` 时可用。 - `MINIO_USE_SSL`:**false**:Minio 启用 ssl,仅在 `STORAGE_TYPE` 为 `minio` 时可用。 - `MINIO_INSECURE_SKIP_VERIFY`:**false**:Minio 跳过 SSL 验证,仅在 `STORAGE_TYPE` 为 `minio` 时可用。 +- `VIRTUAL_HOST`: **false**: Minio 使用虚拟托管样式而不是路径样式,仅当 STORAGE_TYPE 为 `minio` 时可用。 建议的 minio 存储配置如下: @@ -1236,6 +1239,8 @@ MINIO_USE_SSL = false ; Minio skip SSL verification available when STORAGE_TYPE is `minio` MINIO_INSECURE_SKIP_VERIFY = false SERVE_DIRECT = true +; Minio use virtual host style instead of path style when STORAGE_TYPE is `minio` +VIRTUAL_HOST = false ``` 默认情况下,每个存储都有其默认的基本路径,如下所示: @@ -1282,6 +1287,8 @@ MINIO_LOCATION = us-east-1 MINIO_USE_SSL = false ; Minio skip SSL verification available when STORAGE_TYPE is `minio` MINIO_INSECURE_SKIP_VERIFY = false +; Minio use virtual host style instead of path style when STORAGE_TYPE is `minio` +VIRTUAL_HOST = false ``` ### 存储库归档存储 (`storage.repo-archive`) @@ -1299,6 +1306,7 @@ MINIO_INSECURE_SKIP_VERIFY = false - `MINIO_BASE_PATH`: **repo-archive/**:存储桶上的Minio基本路径,仅在`STORAGE_TYPE`为`minio`时可用。 - `MINIO_USE_SSL`: **false**:启用Minio的SSL,仅在`STORAGE_TYPE`为`minio`时可用。 - `MINIO_INSECURE_SKIP_VERIFY`: **false**:跳过Minio的SSL验证,仅在`STORAGE_TYPE`为`minio`时可用。 +- `VIRTUAL_HOST`: **false**: Minio 使用虚拟托管样式而不是路径样式,仅当 STORAGE_TYPE 为 `minio` 时可用。 ### 存储库归档 (`repo-archive`) From 1306ff62523e3d198d77e045ac1c7d9fd3bdb119 Mon Sep 17 00:00:00 2001 From: dicarne Date: Tue, 14 May 2024 14:49:01 +0800 Subject: [PATCH 05/12] Change Minio lookup type to enum. --- custom/conf/app.example.ini | 4 ++-- .../administration/config-cheat-sheet.en-us.md | 17 ++++++++--------- .../administration/config-cheat-sheet.zh-cn.md | 16 ++++++++-------- modules/setting/storage.go | 2 +- modules/storage/minio.go | 7 ++++++- 5 files changed, 25 insertions(+), 21 deletions(-) diff --git a/custom/conf/app.example.ini b/custom/conf/app.example.ini index eb201745c4662..6e6334c6de5e5 100644 --- a/custom/conf/app.example.ini +++ b/custom/conf/app.example.ini @@ -1896,8 +1896,8 @@ LEVEL = Info ;; Minio checksum algorithm: default (for MinIO or AWS S3) or md5 (for Cloudflare or Backblaze) ;MINIO_CHECKSUM_ALGORITHM = default ;; -;; Minio use virtual host style instead of path style when STORAGE_TYPE is `minio` -;VIRTUAL_HOST = false +;; Minio bucket lookup method defaults to auto mode; set it to `dns` for virtual host style or `path` for path style, only available when STORAGE_TYPE is `minio` +;MINIO_LOOKUP_TYPE = auto ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; diff --git a/docs/content/administration/config-cheat-sheet.en-us.md b/docs/content/administration/config-cheat-sheet.en-us.md index 0d1338b8afbe2..58cfb1c6a9e25 100644 --- a/docs/content/administration/config-cheat-sheet.en-us.md +++ b/docs/content/administration/config-cheat-sheet.en-us.md @@ -851,7 +851,7 @@ Default templates for project boards: - `MINIO_USE_SSL`: **false**: Minio enabled ssl only available when STORAGE_TYPE is `minio` - `MINIO_INSECURE_SKIP_VERIFY`: **false**: Minio skip SSL verification available when STORAGE_TYPE is `minio` - `MINIO_CHECKSUM_ALGORITHM`: **default**: Minio checksum algorithm: `default` (for MinIO or AWS S3) or `md5` (for Cloudflare or Backblaze) -- `VIRTUAL_HOST`: **false**: Minio use virtual host style instead of path style when STORAGE_TYPE is `minio` +- `MINIO_LOOKUP_TYPE`: **auto**: Minio bucket lookup method defaults to auto mode; set it to `dns` for virtual host style or `path` for path style, only available when STORAGE_TYPE is `minio` ## Log (`log`) @@ -1273,7 +1273,7 @@ is `data/lfs` and the default of `MINIO_BASE_PATH` is `lfs/`. - `MINIO_BASE_PATH`: **lfs/**: Minio base path on the bucket only available when `STORAGE_TYPE` is `minio` - `MINIO_USE_SSL`: **false**: Minio enabled ssl only available when `STORAGE_TYPE` is `minio` - `MINIO_INSECURE_SKIP_VERIFY`: **false**: Minio skip SSL verification available when STORAGE_TYPE is `minio` -- `VIRTUAL_HOST`: **false**: Minio use virtual host style instead of path style when STORAGE_TYPE is `minio` +- `MINIO_LOOKUP_TYPE`: **auto**: Minio bucket lookup method defaults to auto mode; set it to `dns` for virtual host style or `path` for path style, only available when STORAGE_TYPE is `minio` ## Storage (`storage`) @@ -1288,7 +1288,7 @@ Default storage configuration for attachments, lfs, avatars, repo-avatars, repo- - `MINIO_LOCATION`: **us-east-1**: Minio location to create bucket only available when `STORAGE_TYPE` is `minio` - `MINIO_USE_SSL`: **false**: Minio enabled ssl only available when `STORAGE_TYPE` is `minio` - `MINIO_INSECURE_SKIP_VERIFY`: **false**: Minio skip SSL verification available when STORAGE_TYPE is `minio` -- `VIRTUAL_HOST`: **false**: Minio use virtual host style instead of path style when STORAGE_TYPE is `minio` +- `MINIO_LOOKUP_TYPE`: **auto**: Minio bucket lookup method defaults to auto mode; set it to `dns` for virtual host style or `path` for path style, only available when STORAGE_TYPE is `minio` The recommended storage configuration for minio like below: @@ -1310,8 +1310,8 @@ MINIO_USE_SSL = false ; Minio skip SSL verification available when STORAGE_TYPE is `minio` MINIO_INSECURE_SKIP_VERIFY = false SERVE_DIRECT = true -; Minio use virtual host style instead of path style when STORAGE_TYPE is `minio` -VIRTUAL_HOST = false +; Minio bucket lookup method defaults to auto mode; set it to `dns` for virtual host style or `path` for path style, only available when STORAGE_TYPE is `minio` +MINIO_LOOKUP_TYPE = auto ``` Defaultly every storage has their default base path like below @@ -1357,9 +1357,8 @@ MINIO_LOCATION = us-east-1 ; Minio enabled ssl only available when STORAGE_TYPE is `minio` MINIO_USE_SSL = false ; Minio skip SSL verification available when STORAGE_TYPE is `minio` -MINIO_INSECURE_SKIP_VERIFY = false -; Minio use virtual host style instead of path style when STORAGE_TYPE is `minio` -VIRTUAL_HOST = false +MINIO_INSECURE_SKIP_VERIFY = false; Minio bucket lookup method defaults to auto mode; set it to `dns` for virtual host style or `path` for path style, only available when STORAGE_TYPE is `minio` +MINIO_LOOKUP_TYPE = auto ``` ## Repository Archive Storage (`storage.repo-archive`) @@ -1379,7 +1378,7 @@ is `data/repo-archive` and the default of `MINIO_BASE_PATH` is `repo-archive/`. - `MINIO_BASE_PATH`: **repo-archive/**: Minio base path on the bucket only available when `STORAGE_TYPE` is `minio` - `MINIO_USE_SSL`: **false**: Minio enabled ssl only available when `STORAGE_TYPE` is `minio` - `MINIO_INSECURE_SKIP_VERIFY`: **false**: Minio skip SSL verification available when STORAGE_TYPE is `minio` -- `VIRTUAL_HOST`: **false**: Minio use virtual host style instead of path style when STORAGE_TYPE is `minio` +- `MINIO_LOOKUP_TYPE`: **auto**: Minio bucket lookup method defaults to auto mode; set it to `dns` for virtual host style or `path` for path style, only available when STORAGE_TYPE is `minio` ## Repository Archives (`repo-archive`) diff --git a/docs/content/administration/config-cheat-sheet.zh-cn.md b/docs/content/administration/config-cheat-sheet.zh-cn.md index 313933acded01..1c9069c3ab47d 100644 --- a/docs/content/administration/config-cheat-sheet.zh-cn.md +++ b/docs/content/administration/config-cheat-sheet.zh-cn.md @@ -796,7 +796,7 @@ Gitea 创建以下非唯一队列: - `MINIO_USE_SSL`: **false**: Minio 启用 SSL,仅当 STORAGE_TYPE 为 `minio` 时可用。 - `MINIO_INSECURE_SKIP_VERIFY`: **false**: Minio 跳过 SSL 验证,仅当 STORAGE_TYPE 为 `minio` 时可用。 - `MINIO_CHECKSUM_ALGORITHM`: **default**: Minio 校验算法:`default`(适用于 MinIO 或 AWS S3)或 `md5`(适用于 Cloudflare 或 Backblaze) -- `VIRTUAL_HOST`: **false**: Minio 使用虚拟托管样式而不是路径样式,仅当 STORAGE_TYPE 为 `minio` 时可用。 +- `MINIO_LOOKUP_TYPE`: **auto**: Minio的bucket查找方式默认为`auto`模式,可将其设置为`dns`(虚拟托管样式)或`path`(路径样式),仅当`STORAGE_TYPE`为`minio`时可用。 ## 日志 (`log`) @@ -1202,7 +1202,7 @@ ALLOW_DATA_URI_IMAGES = true - `MINIO_BASE_PATH`:**lfs/**:桶上的 Minio 基本路径,仅在 `STORAGE_TYPE` 为 `minio` 时可用。 - `MINIO_USE_SSL`:**false**:Minio 启用 ssl,仅在 `STORAGE_TYPE` 为 `minio` 时可用。 - `MINIO_INSECURE_SKIP_VERIFY`:**false**:Minio 跳过 SSL 验证,仅在 `STORAGE_TYPE` 为 `minio` 时可用。 -- `VIRTUAL_HOST`: **false**: Minio 使用虚拟托管样式而不是路径样式,仅当 STORAGE_TYPE 为 `minio` 时可用。 +- `MINIO_LOOKUP_TYPE`: **auto**: Minio的bucket查找方式默认为`auto`模式,可将其设置为`dns`(虚拟托管样式)或`path`(路径样式),仅当`STORAGE_TYPE`为`minio`时可用。 ## 存储 (`storage`) @@ -1217,7 +1217,7 @@ ALLOW_DATA_URI_IMAGES = true - `MINIO_LOCATION`:**us-east-1**:创建桶的 Minio 位置,仅在 `STORAGE_TYPE` 为 `minio` 时可用。 - `MINIO_USE_SSL`:**false**:Minio 启用 ssl,仅在 `STORAGE_TYPE` 为 `minio` 时可用。 - `MINIO_INSECURE_SKIP_VERIFY`:**false**:Minio 跳过 SSL 验证,仅在 `STORAGE_TYPE` 为 `minio` 时可用。 -- `VIRTUAL_HOST`: **false**: Minio 使用虚拟托管样式而不是路径样式,仅当 STORAGE_TYPE 为 `minio` 时可用。 +- `MINIO_LOOKUP_TYPE`: **auto**: Minio的bucket查找方式默认为`auto`模式,可将其设置为`dns`(虚拟托管样式)或`path`(路径样式),仅当`STORAGE_TYPE`为`minio`时可用。 建议的 minio 存储配置如下: @@ -1239,8 +1239,8 @@ MINIO_USE_SSL = false ; Minio skip SSL verification available when STORAGE_TYPE is `minio` MINIO_INSECURE_SKIP_VERIFY = false SERVE_DIRECT = true -; Minio use virtual host style instead of path style when STORAGE_TYPE is `minio` -VIRTUAL_HOST = false +; Minio bucket lookup method defaults to auto mode; set it to `dns` for virtual host style or `path` for path style, only available when STORAGE_TYPE is `minio` +MINIO_LOOKUP_TYPE = auto ``` 默认情况下,每个存储都有其默认的基本路径,如下所示: @@ -1287,8 +1287,8 @@ MINIO_LOCATION = us-east-1 MINIO_USE_SSL = false ; Minio skip SSL verification available when STORAGE_TYPE is `minio` MINIO_INSECURE_SKIP_VERIFY = false -; Minio use virtual host style instead of path style when STORAGE_TYPE is `minio` -VIRTUAL_HOST = false +; Minio bucket lookup method defaults to auto mode; set it to `dns` for virtual host style or `path` for path style, only available when STORAGE_TYPE is `minio` +MINIO_LOOKUP_TYPE = auto ``` ### 存储库归档存储 (`storage.repo-archive`) @@ -1306,7 +1306,7 @@ VIRTUAL_HOST = false - `MINIO_BASE_PATH`: **repo-archive/**:存储桶上的Minio基本路径,仅在`STORAGE_TYPE`为`minio`时可用。 - `MINIO_USE_SSL`: **false**:启用Minio的SSL,仅在`STORAGE_TYPE`为`minio`时可用。 - `MINIO_INSECURE_SKIP_VERIFY`: **false**:跳过Minio的SSL验证,仅在`STORAGE_TYPE`为`minio`时可用。 -- `VIRTUAL_HOST`: **false**: Minio 使用虚拟托管样式而不是路径样式,仅当 STORAGE_TYPE 为 `minio` 时可用。 +- `MINIO_LOOKUP_TYPE`: **auto**: Minio的bucket查找方式默认为`auto`模式,可将其设置为`dns`(虚拟托管样式)或`path`(路径样式),仅当`STORAGE_TYPE`为`minio`时可用。 ### 存储库归档 (`repo-archive`) diff --git a/modules/setting/storage.go b/modules/setting/storage.go index 57188218fdc33..551d571779b7d 100644 --- a/modules/setting/storage.go +++ b/modules/setting/storage.go @@ -47,7 +47,7 @@ type MinioStorageConfig struct { InsecureSkipVerify bool `ini:"MINIO_INSECURE_SKIP_VERIFY"` ChecksumAlgorithm string `ini:"MINIO_CHECKSUM_ALGORITHM" json:",omitempty"` ServeDirect bool `ini:"SERVE_DIRECT"` - VirtualHost bool `ini:"VIRTUAL_HOST"` + LookUpType string `ini:"MINIO_LOOKUP_TYPE"` } // Storage represents configuration of storages diff --git a/modules/storage/minio.go b/modules/storage/minio.go index afaf8d2c50a18..1fbc555f0848c 100644 --- a/modules/storage/minio.go +++ b/modules/storage/minio.go @@ -86,9 +86,14 @@ func NewMinioStorage(ctx context.Context, cfg *setting.Storage) (ObjectStorage, log.Info("Creating Minio storage at %s:%s with base path %s", config.Endpoint, config.Bucket, config.BasePath) lookup := minio.BucketLookupAuto - if config.VirtualHost { + if config.LookUpType == "dns" { lookup = minio.BucketLookupDNS + } else if config.LookUpType == "path" { + lookup = minio.BucketLookupPath + } else if !(config.LookUpType == "auto" || config.LookUpType == "") { + return nil, fmt.Errorf("invalid minio bucket lookup type: %s", config.LookUpType) } + minioClient, err := minio.New(config.Endpoint, &minio.Options{ Creds: credentials.NewStaticV4(config.AccessKeyID, config.SecretAccessKey, ""), Secure: config.UseSSL, From 016a88496ae599b05a91e76fed99a31209499e9c Mon Sep 17 00:00:00 2001 From: dicarne Date: Tue, 14 May 2024 14:51:56 +0800 Subject: [PATCH 06/12] Fix the error of MINIO_LOOKUP_TYPE in app.example.ini. --- custom/conf/app.example.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/custom/conf/app.example.ini b/custom/conf/app.example.ini index 6e6334c6de5e5..eded3e145b2d0 100644 --- a/custom/conf/app.example.ini +++ b/custom/conf/app.example.ini @@ -2580,8 +2580,8 @@ LEVEL = Info ;; Minio skip SSL verification available when STORAGE_TYPE is `minio` ;MINIO_INSECURE_SKIP_VERIFY = false ;; -;; Minio use virtual host style instead of path style when STORAGE_TYPE is `minio` -;VIRTUAL_HOST = false +;; Minio bucket lookup method defaults to auto mode; set it to `dns` for virtual host style or `path` for path style, only available when STORAGE_TYPE is `minio` +;MINIO_LOOKUP_TYPE = auto ;[proxy] ;; Enable the proxy, all requests to external via HTTP will be affected From 792a9c39f9ff916e69ee8f2c5737b3d42024e66a Mon Sep 17 00:00:00 2001 From: dicarne Date: Tue, 14 May 2024 14:59:35 +0800 Subject: [PATCH 07/12] Change MINIO_LOOKUP_TYPE to MINIO_BUCKET_LOOKUP_TYPE, make it more precise. --- custom/conf/app.example.ini | 4 ++-- .../administration/config-cheat-sheet.en-us.md | 12 ++++++------ .../administration/config-cheat-sheet.zh-cn.md | 12 ++++++------ modules/setting/storage.go | 2 +- modules/storage/minio.go | 8 ++++---- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/custom/conf/app.example.ini b/custom/conf/app.example.ini index eded3e145b2d0..4df843b8cef2a 100644 --- a/custom/conf/app.example.ini +++ b/custom/conf/app.example.ini @@ -1897,7 +1897,7 @@ LEVEL = Info ;MINIO_CHECKSUM_ALGORITHM = default ;; ;; Minio bucket lookup method defaults to auto mode; set it to `dns` for virtual host style or `path` for path style, only available when STORAGE_TYPE is `minio` -;MINIO_LOOKUP_TYPE = auto +;MINIO_BUCKET_LOOKUP_TYPE = auto ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -2581,7 +2581,7 @@ LEVEL = Info ;MINIO_INSECURE_SKIP_VERIFY = false ;; ;; Minio bucket lookup method defaults to auto mode; set it to `dns` for virtual host style or `path` for path style, only available when STORAGE_TYPE is `minio` -;MINIO_LOOKUP_TYPE = auto +;MINIO_BUCKET_LOOKUP_TYPE = auto ;[proxy] ;; Enable the proxy, all requests to external via HTTP will be affected diff --git a/docs/content/administration/config-cheat-sheet.en-us.md b/docs/content/administration/config-cheat-sheet.en-us.md index 58cfb1c6a9e25..539c5fb501eef 100644 --- a/docs/content/administration/config-cheat-sheet.en-us.md +++ b/docs/content/administration/config-cheat-sheet.en-us.md @@ -851,7 +851,7 @@ Default templates for project boards: - `MINIO_USE_SSL`: **false**: Minio enabled ssl only available when STORAGE_TYPE is `minio` - `MINIO_INSECURE_SKIP_VERIFY`: **false**: Minio skip SSL verification available when STORAGE_TYPE is `minio` - `MINIO_CHECKSUM_ALGORITHM`: **default**: Minio checksum algorithm: `default` (for MinIO or AWS S3) or `md5` (for Cloudflare or Backblaze) -- `MINIO_LOOKUP_TYPE`: **auto**: Minio bucket lookup method defaults to auto mode; set it to `dns` for virtual host style or `path` for path style, only available when STORAGE_TYPE is `minio` +- `MINIO_BUCKET_LOOKUP_TYPE`: **auto**: Minio bucket lookup method defaults to auto mode; set it to `dns` for virtual host style or `path` for path style, only available when STORAGE_TYPE is `minio` ## Log (`log`) @@ -1273,7 +1273,7 @@ is `data/lfs` and the default of `MINIO_BASE_PATH` is `lfs/`. - `MINIO_BASE_PATH`: **lfs/**: Minio base path on the bucket only available when `STORAGE_TYPE` is `minio` - `MINIO_USE_SSL`: **false**: Minio enabled ssl only available when `STORAGE_TYPE` is `minio` - `MINIO_INSECURE_SKIP_VERIFY`: **false**: Minio skip SSL verification available when STORAGE_TYPE is `minio` -- `MINIO_LOOKUP_TYPE`: **auto**: Minio bucket lookup method defaults to auto mode; set it to `dns` for virtual host style or `path` for path style, only available when STORAGE_TYPE is `minio` +- `MINIO_BUCKET_LOOKUP_TYPE`: **auto**: Minio bucket lookup method defaults to auto mode; set it to `dns` for virtual host style or `path` for path style, only available when STORAGE_TYPE is `minio` ## Storage (`storage`) @@ -1288,7 +1288,7 @@ Default storage configuration for attachments, lfs, avatars, repo-avatars, repo- - `MINIO_LOCATION`: **us-east-1**: Minio location to create bucket only available when `STORAGE_TYPE` is `minio` - `MINIO_USE_SSL`: **false**: Minio enabled ssl only available when `STORAGE_TYPE` is `minio` - `MINIO_INSECURE_SKIP_VERIFY`: **false**: Minio skip SSL verification available when STORAGE_TYPE is `minio` -- `MINIO_LOOKUP_TYPE`: **auto**: Minio bucket lookup method defaults to auto mode; set it to `dns` for virtual host style or `path` for path style, only available when STORAGE_TYPE is `minio` +- `MINIO_BUCKET_LOOKUP_TYPE`: **auto**: Minio bucket lookup method defaults to auto mode; set it to `dns` for virtual host style or `path` for path style, only available when STORAGE_TYPE is `minio` The recommended storage configuration for minio like below: @@ -1311,7 +1311,7 @@ MINIO_USE_SSL = false MINIO_INSECURE_SKIP_VERIFY = false SERVE_DIRECT = true ; Minio bucket lookup method defaults to auto mode; set it to `dns` for virtual host style or `path` for path style, only available when STORAGE_TYPE is `minio` -MINIO_LOOKUP_TYPE = auto +MINIO_BUCKET_LOOKUP_TYPE = auto ``` Defaultly every storage has their default base path like below @@ -1358,7 +1358,7 @@ MINIO_LOCATION = us-east-1 MINIO_USE_SSL = false ; Minio skip SSL verification available when STORAGE_TYPE is `minio` MINIO_INSECURE_SKIP_VERIFY = false; Minio bucket lookup method defaults to auto mode; set it to `dns` for virtual host style or `path` for path style, only available when STORAGE_TYPE is `minio` -MINIO_LOOKUP_TYPE = auto +MINIO_BUCKET_LOOKUP_TYPE = auto ``` ## Repository Archive Storage (`storage.repo-archive`) @@ -1378,7 +1378,7 @@ is `data/repo-archive` and the default of `MINIO_BASE_PATH` is `repo-archive/`. - `MINIO_BASE_PATH`: **repo-archive/**: Minio base path on the bucket only available when `STORAGE_TYPE` is `minio` - `MINIO_USE_SSL`: **false**: Minio enabled ssl only available when `STORAGE_TYPE` is `minio` - `MINIO_INSECURE_SKIP_VERIFY`: **false**: Minio skip SSL verification available when STORAGE_TYPE is `minio` -- `MINIO_LOOKUP_TYPE`: **auto**: Minio bucket lookup method defaults to auto mode; set it to `dns` for virtual host style or `path` for path style, only available when STORAGE_TYPE is `minio` +- `MINIO_BUCKET_LOOKUP_TYPE`: **auto**: Minio bucket lookup method defaults to auto mode; set it to `dns` for virtual host style or `path` for path style, only available when STORAGE_TYPE is `minio` ## Repository Archives (`repo-archive`) diff --git a/docs/content/administration/config-cheat-sheet.zh-cn.md b/docs/content/administration/config-cheat-sheet.zh-cn.md index 1c9069c3ab47d..3c6ac8c00afb7 100644 --- a/docs/content/administration/config-cheat-sheet.zh-cn.md +++ b/docs/content/administration/config-cheat-sheet.zh-cn.md @@ -796,7 +796,7 @@ Gitea 创建以下非唯一队列: - `MINIO_USE_SSL`: **false**: Minio 启用 SSL,仅当 STORAGE_TYPE 为 `minio` 时可用。 - `MINIO_INSECURE_SKIP_VERIFY`: **false**: Minio 跳过 SSL 验证,仅当 STORAGE_TYPE 为 `minio` 时可用。 - `MINIO_CHECKSUM_ALGORITHM`: **default**: Minio 校验算法:`default`(适用于 MinIO 或 AWS S3)或 `md5`(适用于 Cloudflare 或 Backblaze) -- `MINIO_LOOKUP_TYPE`: **auto**: Minio的bucket查找方式默认为`auto`模式,可将其设置为`dns`(虚拟托管样式)或`path`(路径样式),仅当`STORAGE_TYPE`为`minio`时可用。 +- `MINIO_BUCKET_LOOKUP_TYPE`: **auto**: Minio的bucket查找方式默认为`auto`模式,可将其设置为`dns`(虚拟托管样式)或`path`(路径样式),仅当`STORAGE_TYPE`为`minio`时可用。 ## 日志 (`log`) @@ -1202,7 +1202,7 @@ ALLOW_DATA_URI_IMAGES = true - `MINIO_BASE_PATH`:**lfs/**:桶上的 Minio 基本路径,仅在 `STORAGE_TYPE` 为 `minio` 时可用。 - `MINIO_USE_SSL`:**false**:Minio 启用 ssl,仅在 `STORAGE_TYPE` 为 `minio` 时可用。 - `MINIO_INSECURE_SKIP_VERIFY`:**false**:Minio 跳过 SSL 验证,仅在 `STORAGE_TYPE` 为 `minio` 时可用。 -- `MINIO_LOOKUP_TYPE`: **auto**: Minio的bucket查找方式默认为`auto`模式,可将其设置为`dns`(虚拟托管样式)或`path`(路径样式),仅当`STORAGE_TYPE`为`minio`时可用。 +- `MINIO_BUCKET_LOOKUP_TYPE`: **auto**: Minio的bucket查找方式默认为`auto`模式,可将其设置为`dns`(虚拟托管样式)或`path`(路径样式),仅当`STORAGE_TYPE`为`minio`时可用。 ## 存储 (`storage`) @@ -1217,7 +1217,7 @@ ALLOW_DATA_URI_IMAGES = true - `MINIO_LOCATION`:**us-east-1**:创建桶的 Minio 位置,仅在 `STORAGE_TYPE` 为 `minio` 时可用。 - `MINIO_USE_SSL`:**false**:Minio 启用 ssl,仅在 `STORAGE_TYPE` 为 `minio` 时可用。 - `MINIO_INSECURE_SKIP_VERIFY`:**false**:Minio 跳过 SSL 验证,仅在 `STORAGE_TYPE` 为 `minio` 时可用。 -- `MINIO_LOOKUP_TYPE`: **auto**: Minio的bucket查找方式默认为`auto`模式,可将其设置为`dns`(虚拟托管样式)或`path`(路径样式),仅当`STORAGE_TYPE`为`minio`时可用。 +- `MINIO_BUCKET_LOOKUP_TYPE`: **auto**: Minio的bucket查找方式默认为`auto`模式,可将其设置为`dns`(虚拟托管样式)或`path`(路径样式),仅当`STORAGE_TYPE`为`minio`时可用。 建议的 minio 存储配置如下: @@ -1240,7 +1240,7 @@ MINIO_USE_SSL = false MINIO_INSECURE_SKIP_VERIFY = false SERVE_DIRECT = true ; Minio bucket lookup method defaults to auto mode; set it to `dns` for virtual host style or `path` for path style, only available when STORAGE_TYPE is `minio` -MINIO_LOOKUP_TYPE = auto +MINIO_BUCKET_LOOKUP_TYPE = auto ``` 默认情况下,每个存储都有其默认的基本路径,如下所示: @@ -1288,7 +1288,7 @@ MINIO_USE_SSL = false ; Minio skip SSL verification available when STORAGE_TYPE is `minio` MINIO_INSECURE_SKIP_VERIFY = false ; Minio bucket lookup method defaults to auto mode; set it to `dns` for virtual host style or `path` for path style, only available when STORAGE_TYPE is `minio` -MINIO_LOOKUP_TYPE = auto +MINIO_BUCKET_LOOKUP_TYPE = auto ``` ### 存储库归档存储 (`storage.repo-archive`) @@ -1306,7 +1306,7 @@ MINIO_LOOKUP_TYPE = auto - `MINIO_BASE_PATH`: **repo-archive/**:存储桶上的Minio基本路径,仅在`STORAGE_TYPE`为`minio`时可用。 - `MINIO_USE_SSL`: **false**:启用Minio的SSL,仅在`STORAGE_TYPE`为`minio`时可用。 - `MINIO_INSECURE_SKIP_VERIFY`: **false**:跳过Minio的SSL验证,仅在`STORAGE_TYPE`为`minio`时可用。 -- `MINIO_LOOKUP_TYPE`: **auto**: Minio的bucket查找方式默认为`auto`模式,可将其设置为`dns`(虚拟托管样式)或`path`(路径样式),仅当`STORAGE_TYPE`为`minio`时可用。 +- `MINIO_BUCKET_LOOKUP_TYPE`: **auto**: Minio的bucket查找方式默认为`auto`模式,可将其设置为`dns`(虚拟托管样式)或`path`(路径样式),仅当`STORAGE_TYPE`为`minio`时可用。 ### 存储库归档 (`repo-archive`) diff --git a/modules/setting/storage.go b/modules/setting/storage.go index 551d571779b7d..76d951b79c253 100644 --- a/modules/setting/storage.go +++ b/modules/setting/storage.go @@ -47,7 +47,7 @@ type MinioStorageConfig struct { InsecureSkipVerify bool `ini:"MINIO_INSECURE_SKIP_VERIFY"` ChecksumAlgorithm string `ini:"MINIO_CHECKSUM_ALGORITHM" json:",omitempty"` ServeDirect bool `ini:"SERVE_DIRECT"` - LookUpType string `ini:"MINIO_LOOKUP_TYPE"` + BucketLookUpType string `ini:"MINIO_BUCKET_LOOKUP_TYPE"` } // Storage represents configuration of storages diff --git a/modules/storage/minio.go b/modules/storage/minio.go index 1fbc555f0848c..951a0a285998e 100644 --- a/modules/storage/minio.go +++ b/modules/storage/minio.go @@ -86,12 +86,12 @@ func NewMinioStorage(ctx context.Context, cfg *setting.Storage) (ObjectStorage, log.Info("Creating Minio storage at %s:%s with base path %s", config.Endpoint, config.Bucket, config.BasePath) lookup := minio.BucketLookupAuto - if config.LookUpType == "dns" { + if config.BucketLookUpType == "dns" { lookup = minio.BucketLookupDNS - } else if config.LookUpType == "path" { + } else if config.BucketLookUpType == "path" { lookup = minio.BucketLookupPath - } else if !(config.LookUpType == "auto" || config.LookUpType == "") { - return nil, fmt.Errorf("invalid minio bucket lookup type: %s", config.LookUpType) + } else if !(config.BucketLookUpType == "auto" || config.BucketLookUpType == "") { + return nil, fmt.Errorf("invalid minio bucket lookup type: %s", config.BucketLookUpType) } minioClient, err := minio.New(config.Endpoint, &minio.Options{ From 299626729fee8b04de92ef724693fb24adaf046f Mon Sep 17 00:00:00 2001 From: dicarne Date: Tue, 14 May 2024 22:01:22 +0800 Subject: [PATCH 08/12] Fix document incorrect formatting. --- docs/content/administration/config-cheat-sheet.en-us.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/content/administration/config-cheat-sheet.en-us.md b/docs/content/administration/config-cheat-sheet.en-us.md index 539c5fb501eef..6c429bb652161 100644 --- a/docs/content/administration/config-cheat-sheet.en-us.md +++ b/docs/content/administration/config-cheat-sheet.en-us.md @@ -1357,7 +1357,8 @@ MINIO_LOCATION = us-east-1 ; Minio enabled ssl only available when STORAGE_TYPE is `minio` MINIO_USE_SSL = false ; Minio skip SSL verification available when STORAGE_TYPE is `minio` -MINIO_INSECURE_SKIP_VERIFY = false; Minio bucket lookup method defaults to auto mode; set it to `dns` for virtual host style or `path` for path style, only available when STORAGE_TYPE is `minio` +MINIO_INSECURE_SKIP_VERIFY = false +; Minio bucket lookup method defaults to auto mode; set it to `dns` for virtual host style or `path` for path style, only available when STORAGE_TYPE is `minio` MINIO_BUCKET_LOOKUP_TYPE = auto ``` From d84e92e8418b345d1e6939e413d40aface48b376 Mon Sep 17 00:00:00 2001 From: dicarne Date: Tue, 14 May 2024 22:03:54 +0800 Subject: [PATCH 09/12] Added default value of `MINIO_BUCKET_LOOKUP_TYPE` to getDefaultStorageSection. --- modules/setting/storage.go | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/setting/storage.go b/modules/setting/storage.go index 76d951b79c253..f2f74a54cf61c 100644 --- a/modules/setting/storage.go +++ b/modules/setting/storage.go @@ -83,6 +83,7 @@ func getDefaultStorageSection(rootCfg ConfigProvider) ConfigSection { storageSec.Key("MINIO_USE_SSL").MustBool(false) storageSec.Key("MINIO_INSECURE_SKIP_VERIFY").MustBool(false) storageSec.Key("MINIO_CHECKSUM_ALGORITHM").MustString("default") + storageSec.Key("MINIO_BUCKET_LOOKUP_TYPE").MustString("auto") return storageSec } From cdbc997f3da6785ccd4e5f9ed6f869ef505cf2f0 Mon Sep 17 00:00:00 2001 From: dicarne Date: Tue, 14 May 2024 22:07:16 +0800 Subject: [PATCH 10/12] Simplfy BucketLookUpType check. --- modules/storage/minio.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/storage/minio.go b/modules/storage/minio.go index 951a0a285998e..1ff4d5189704b 100644 --- a/modules/storage/minio.go +++ b/modules/storage/minio.go @@ -90,7 +90,7 @@ func NewMinioStorage(ctx context.Context, cfg *setting.Storage) (ObjectStorage, lookup = minio.BucketLookupDNS } else if config.BucketLookUpType == "path" { lookup = minio.BucketLookupPath - } else if !(config.BucketLookUpType == "auto" || config.BucketLookUpType == "") { + } else if config.BucketLookUpType != "auto" { return nil, fmt.Errorf("invalid minio bucket lookup type: %s", config.BucketLookUpType) } From 96171b84fabcd9d8d454a68a1f71da7c983197cc Mon Sep 17 00:00:00 2001 From: dicarne Date: Wed, 15 May 2024 10:37:15 +0800 Subject: [PATCH 11/12] Add option to migrate_storage --- cmd/migrate_storage.go | 6 ++++++ modules/setting/storage.go | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/cmd/migrate_storage.go b/cmd/migrate_storage.go index 357416fc339fd..7d1ef052ffc19 100644 --- a/cmd/migrate_storage.go +++ b/cmd/migrate_storage.go @@ -91,6 +91,11 @@ var CmdMigrateStorage = &cli.Command{ Value: "", Usage: "Minio checksum algorithm (default/md5)", }, + &cli.StringFlag{ + Name: "minio-bucket-lookup-type", + Value: "", + Usage: "Minio bucket lookup type", + }, }, } @@ -220,6 +225,7 @@ func runMigrateStorage(ctx *cli.Context) error { UseSSL: ctx.Bool("minio-use-ssl"), InsecureSkipVerify: ctx.Bool("minio-insecure-skip-verify"), ChecksumAlgorithm: ctx.String("minio-checksum-algorithm"), + BucketLookUpType: ctx.String("minio-bucket-lookup-type"), }, }) default: diff --git a/modules/setting/storage.go b/modules/setting/storage.go index f2f74a54cf61c..d80a61a45eb30 100644 --- a/modules/setting/storage.go +++ b/modules/setting/storage.go @@ -47,7 +47,7 @@ type MinioStorageConfig struct { InsecureSkipVerify bool `ini:"MINIO_INSECURE_SKIP_VERIFY"` ChecksumAlgorithm string `ini:"MINIO_CHECKSUM_ALGORITHM" json:",omitempty"` ServeDirect bool `ini:"SERVE_DIRECT"` - BucketLookUpType string `ini:"MINIO_BUCKET_LOOKUP_TYPE"` + BucketLookUpType string `ini:"MINIO_BUCKET_LOOKUP_TYPE" json:",omitempty"` } // Storage represents configuration of storages From 49a4f9e40f0d3dc1aa718045334c605554f77658 Mon Sep 17 00:00:00 2001 From: dicarne Date: Wed, 15 May 2024 10:54:11 +0800 Subject: [PATCH 12/12] Added MINIO_BUCKET_LOOKUP_TYPE processing of empty strings. --- modules/storage/minio.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/storage/minio.go b/modules/storage/minio.go index 1ff4d5189704b..986332dfed77d 100644 --- a/modules/storage/minio.go +++ b/modules/storage/minio.go @@ -85,12 +85,14 @@ func NewMinioStorage(ctx context.Context, cfg *setting.Storage) (ObjectStorage, log.Info("Creating Minio storage at %s:%s with base path %s", config.Endpoint, config.Bucket, config.BasePath) - lookup := minio.BucketLookupAuto - if config.BucketLookUpType == "dns" { + var lookup minio.BucketLookupType + if config.BucketLookUpType == "auto" || config.BucketLookUpType == "" { + lookup = minio.BucketLookupAuto + } else if config.BucketLookUpType == "dns" { lookup = minio.BucketLookupDNS } else if config.BucketLookUpType == "path" { lookup = minio.BucketLookupPath - } else if config.BucketLookUpType != "auto" { + } else { return nil, fmt.Errorf("invalid minio bucket lookup type: %s", config.BucketLookUpType) }