fix: make s3_region configurable to support values other than "garage"

This commit is contained in:
2024-10-13 23:39:22 +00:00
parent c1619276c0
commit 37027396ca
3 changed files with 15 additions and 3 deletions
+13 -1
View File
@@ -3,6 +3,7 @@ package utils
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"io"
"khairul169/garage-webui/schema"
@@ -73,6 +74,17 @@ func (g *garage) GetS3Endpoint() string {
return endpoint
}
func (g *garage) GetS3Region() string {
endpoint := os.Getenv("S3_REGION")
if len(endpoint) > 0 {
return endpoint
}
if len(g.Config.S3API.S3Region) == 0 {
return "garage"
}
return g.Config.S3API.S3Region
}
func (g *garage) GetAdminKey() string {
key := os.Getenv("API_ADMIN_KEY")
if len(key) > 0 {
@@ -153,7 +165,7 @@ func (g *garage) Fetch(url string, options *FetchOptions) ([]byte, error) {
message = fmt.Sprintf("%v", data["message"])
}
return nil, fmt.Errorf(message)
return nil, errors.New(message)
}
body, err := io.ReadAll(res.Body)