mirror of
https://github.com/khairul169/garage-webui.git
synced 2025-04-27 22:39:31 +07:00
fix: make s3_region configurable to support values other than "garage"
This commit is contained in:
parent
c1619276c0
commit
37027396ca
@ -16,7 +16,7 @@ func main() {
|
||||
utils.InitCacheManager()
|
||||
|
||||
if err := utils.Garage.LoadConfig(); err != nil {
|
||||
log.Fatal("Failed to load config! ", err)
|
||||
log.Println("Cannot load garage config!", err)
|
||||
}
|
||||
|
||||
http.Handle("/api/", http.StripPrefix("/api", router.HandleApiRouter()))
|
||||
|
@ -300,7 +300,7 @@ func getS3Client(bucket string) (*s3.Client, error) {
|
||||
|
||||
awsConfig := aws.Config{
|
||||
Credentials: creds,
|
||||
Region: "garage",
|
||||
Region: utils.Garage.GetS3Region(),
|
||||
BaseEndpoint: aws.String(utils.Garage.GetS3Endpoint()),
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user