Skip to content

Commit 1f2897c

Browse files
committed
优化 MinIO 自动配置和属性默认值
- 增加对默认 endpoint 和 port 的日志警告 - 优化 endpoint 和 port 的默认值处理逻辑 - 更新 MinioProperties 默认值以允许为空
1 parent a2e5b83 commit 1f2897c

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

oss/oss-minio/src/main/kotlin/io/github/truenine/composeserver/oss/minio/autoconfig/MinioAutoConfiguration.kt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,14 @@ class MinioAutoConfiguration {
3939
@Bean
4040
@ConditionalOnMissingBean
4141
fun minioClient(ossProperties: OssProperties, environment: Environment, minioProperties: MinioProperties): MinioClient {
42-
val endpoint = minioProperties.endpoint?.takeIf { it.isNotBlank() } ?: ossProperties.endpoint
43-
val port = minioProperties.port ?: MinioProperties.DEFAULT_PORT
42+
val endpoint =
43+
minioProperties.endpoint?.takeIf { it.isNotBlank() }
44+
?: ossProperties.endpoint
45+
?: MinioProperties.DEFAULT_ENDPOINT.also { it: String -> log.warn("use default endpoint {}", it) }
46+
require(endpoint.isNotBlank()) { "MinIO endpoint is required" }
47+
val port = minioProperties.port ?: MinioProperties.DEFAULT_PORT.also { log.warn("use default port: {}", it) }
4448
val accessKey = minioProperties.accessKey ?: ossProperties.accessKey
4549
val secretKey = minioProperties.secretKey ?: ossProperties.secretKey
46-
require(!endpoint.isNullOrBlank()) { "MinIO endpoint is required" }
4750
val enableSsl = endpoint.startsWith("https://") || ossProperties.enableSsl || (minioProperties.enableSsl == true)
4851

4952
require(!accessKey.isNullOrBlank()) { "MinIO access key is required" }

oss/oss-minio/src/main/kotlin/io/github/truenine/composeserver/oss/minio/properties/MinioProperties.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ import org.springframework.boot.context.properties.ConfigurationProperties
2424
*/
2525
@ConfigurationProperties(prefix = SpringBootConfigurationPropertiesPrefixes.OSS_MINIO)
2626
data class MinioProperties(
27-
var endpoint: String? = DEFAULT_ENDPOINT,
28-
var port: Int? = DEFAULT_PORT,
27+
var endpoint: String? = null,
28+
var port: Int? = null,
2929
var accessKey: String? = null,
3030
var secretKey: String? = null,
3131
var exposedBaseUrl: String? = null,

0 commit comments

Comments
 (0)