mirror of
https://github.com/khairul169/garage-webui.git
synced 2026-09-15 00:43:21 +07:00
fix: make s3_region configurable to support values other than "garage"
This commit is contained in:
+13
-1
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user