diff --git a/config/config.go b/config/config.go index d57e264..9ec076a 100644 --- a/config/config.go +++ b/config/config.go @@ -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", ""), }, } } diff --git a/internal/mediaStorage/handler.go b/internal/mediaStorage/handler.go index 90732d0..ab1331e 100644 --- a/internal/mediaStorage/handler.go +++ b/internal/mediaStorage/handler.go @@ -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), }