38 lines
965 B
Go
38 lines
965 B
Go
package config
|
|
|
|
import "fmt"
|
|
|
|
// Minio
|
|
// @description: Minio配置
|
|
type MinioConfig struct {
|
|
Endpoint string `mapstructure:"endpoint"` // 接口地址
|
|
Host string `mapstructure:"host"` // 自定义域名
|
|
AccessKeyID string `mapstructure:"accessKey"` // 账号
|
|
SecretAccessKey string `mapstructure:"secretKey"` // 密码
|
|
BucketName string `mapstructure:"bucket"` // 桶名称
|
|
UseSsl bool `mapstructure:"useSSL"` // 是否使用SSL
|
|
}
|
|
|
|
// Validate
|
|
// @description: 验证参数
|
|
// @receiver c
|
|
// @return error
|
|
func (c *MinioConfig) Validate() error {
|
|
if c.Endpoint == "" {
|
|
return fmt.Errorf("endpoint is required")
|
|
}
|
|
if c.Host == "" {
|
|
return fmt.Errorf("host is required")
|
|
}
|
|
if c.AccessKeyID == "" {
|
|
return fmt.Errorf("accessKeyId is required")
|
|
}
|
|
if c.SecretAccessKey == "" {
|
|
return fmt.Errorf("secretAccessKey is required")
|
|
}
|
|
if c.BucketName == "" {
|
|
c.BucketName = "wechat"
|
|
}
|
|
return nil
|
|
}
|