create client log + secure mode env
All checks were successful
/ Make image (push) Successful in 1m21s

This commit is contained in:
nquidox 2025-10-16 15:41:52 +03:00
parent 95b75d0067
commit 2d2afffcaf
2 changed files with 14 additions and 2 deletions

View file

@ -46,6 +46,7 @@ type MediaConfig struct {
Port string Port string
User string User string
Password string Password string
Secure string
} }
func NewConfig() *Config { func NewConfig() *Config {
@ -86,6 +87,7 @@ func NewConfig() *Config {
Port: getEnv("MEDIA_STORAGE_PORT", ""), Port: getEnv("MEDIA_STORAGE_PORT", ""),
User: getEnv("MEDIA_STORAGE_USER", ""), User: getEnv("MEDIA_STORAGE_USER", ""),
Password: getEnv("MEDIA_STORAGE_PASSWORD", ""), Password: getEnv("MEDIA_STORAGE_PASSWORD", ""),
Secure: getEnv("MEDIA_STORAGE_SECURE", ""),
}, },
} }
} }

View file

@ -16,19 +16,29 @@ type Deps struct {
Port string Port string
User string User string
Password string Password string
Secure string
} }
func NewHandler(deps Deps) *Handler { func NewHandler(deps Deps) *Handler {
secureMode := false
if deps.Secure == "true" {
secureMode = true
}
endpoint := fmt.Sprintf("%s:%s", deps.Host, deps.Port) endpoint := fmt.Sprintf("%s:%s", deps.Host, deps.Port)
minioClient, err := minio.New(endpoint, &minio.Options{ minioClient, err := minio.New(endpoint, &minio.Options{
Creds: credentials.NewStaticV4(deps.User, deps.Password, ""), Creds: credentials.NewStaticV4(deps.User, deps.Password, ""),
Secure: false, Secure: secureMode,
}) })
if err != nil { if err != nil {
log.WithError(err).Fatal("Media storage | Failed to create minio client") log.WithError(err).Fatal("Media storage | Failed to create minio client")
} }
log.WithFields(log.Fields{
"endpoint": endpoint,
"secure": secureMode,
}).Debug("Media storage | Created minio client")
return &Handler{ return &Handler{
newService(minioClient), newService(minioClient),
} }