create client log + secure mode env
All checks were successful
/ Make image (push) Successful in 1m21s
All checks were successful
/ Make image (push) Successful in 1m21s
This commit is contained in:
parent
95b75d0067
commit
2d2afffcaf
2 changed files with 14 additions and 2 deletions
|
|
@ -46,6 +46,7 @@ type MediaConfig struct {
|
|||
Port string
|
||||
User string
|
||||
Password string
|
||||
Secure string
|
||||
}
|
||||
|
||||
func NewConfig() *Config {
|
||||
|
|
@ -86,6 +87,7 @@ func NewConfig() *Config {
|
|||
Port: getEnv("MEDIA_STORAGE_PORT", ""),
|
||||
User: getEnv("MEDIA_STORAGE_USER", ""),
|
||||
Password: getEnv("MEDIA_STORAGE_PASSWORD", ""),
|
||||
Secure: getEnv("MEDIA_STORAGE_SECURE", ""),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,19 +16,29 @@ type Deps struct {
|
|||
Port string
|
||||
User string
|
||||
Password string
|
||||
Secure string
|
||||
}
|
||||
|
||||
func NewHandler(deps Deps) *Handler {
|
||||
secureMode := false
|
||||
if deps.Secure == "true" {
|
||||
secureMode = true
|
||||
}
|
||||
|
||||
endpoint := fmt.Sprintf("%s:%s", deps.Host, deps.Port)
|
||||
minioClient, err := minio.New(endpoint, &minio.Options{
|
||||
Creds: credentials.NewStaticV4(deps.User, deps.Password, ""),
|
||||
Secure: false,
|
||||
Secure: secureMode,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
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{
|
||||
newService(minioClient),
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue