S3Properties.kt
/*
Copyright (C) 2026 Sber
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
In any derivative products, you must retain the information of
owner of the original code and provide clear attribution to the project
https://dochub.info
The use of this product or its derivatives for any purpose cannot be a secret.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Maintainers:
Sergeev Viktor <sergeevviktor017@gmail.com>, Sber - 2026
Contributors:
Sergeev Viktor <sergeevviktor017@gmail.com>, Sber - 2026
*/
package org.archtool.fileloader2.configuration.properties
import jakarta.validation.constraints.NotBlank
import jakarta.validation.constraints.Positive
import org.springframework.boot.context.properties.ConfigurationProperties
import org.springframework.validation.annotation.Validated
/**
* Хранилище S3, переменные окружения SEAF_FILELOADER_S3_*.
* Адрес, bucket и ключи доступа обязательны и не имеют значения по умолчанию: без них сервис не запускается
*/
@ConfigurationProperties("seaf.fileloader.s3")
@Validated
class S3Properties(
@field:NotBlank(message = "Адрес S3 не задан (SEAF_FILELOADER_S3_URL)")
val url: String,
@field:NotBlank(message = "Регион S3 не задан (SEAF_FILELOADER_S3_REGION)")
val region: String,
@field:NotBlank(message = "Имя bucket не задано (SEAF_FILELOADER_S3_BUCKET_NAME)")
val bucketName: String,
@field:NotBlank(message = "Ключ доступа S3 не задан (SEAF_FILELOADER_S3_ACCESS_KEY_ID)")
val accessKeyId: String,
@field:NotBlank(message = "Секретный ключ S3 не задан (SEAF_FILELOADER_S3_SECRET_ACCESS_KEY)")
val secretAccessKey: String,
/** true - bucket в пути адреса, false - bucket в имени хоста */
val pathStyleAccessEnabled: Boolean,
/** Менять только вместе с переносом объектов под новый префикс */
val keyPrefix: String,
/** Число попыток одного запроса к S3 при временных сбоях, включая первую. 1 - без повторов */
@field:Positive(message = "Число попыток обращения к S3 должно быть положительным (SEAF_FILELOADER_S3_MAX_ATTEMPTS)")
val maxAttempts: Int,
/** Пусто - стандартные корневые сертификаты JVM */
val trustKeyStoreLocation: String? = null,
val trustKeyStorePassword: String? = null,
) {
/**
* @return описание настроек без ключей доступа и пароля keystore, чтобы они не попали в журнал
*/
override fun toString(): String =
"S3Properties(url=$url, region=$region, bucketName=$bucketName, pathStyleAccessEnabled=$pathStyleAccessEnabled, " +
"keyPrefix=$keyPrefix, maxAttempts=$maxAttempts, trustKeyStoreLocation=$trustKeyStoreLocation)"
}