summaryrefslogtreecommitdiff
path: root/config
diff options
from:
to:
context:
space:
mode:
Diffstat (limited to 'config')
-rw-r--r--config/config.go18
1 files changed, 17 insertions, 1 deletions
diff --git a/config/config.go b/config/config.go
index b41be13..543413f 100644
--- a/config/config.go
+++ b/config/config.go
@@ -24,7 +24,7 @@ type DraftModeConfig struct {
}
type StorageConfig struct {
- Type string `json:"Type" validate:"required,oneof=b2"`
+ Type string `json:"Type" validate:"required,oneof=b2 s3"`
Config any `json:"Config" validate:"required"`
}
@@ -47,6 +47,12 @@ func (sc *StorageConfig) UnmarshalJSON(data []byte) error {
return fmt.Errorf("unmarshal B2Config: %w", err)
}
sc.Config = &b2Config
+ case "s3":
+ var s3Config S3Config
+ if err := json.Unmarshal(tmp.Config, &s3Config); err != nil {
+ return fmt.Errorf("unmarshal S3Config: %w", err)
+ }
+ sc.Config = &s3Config
default:
return fmt.Errorf("unsupported storage type: %s", tmp.Type)
}
@@ -62,6 +68,16 @@ type B2Config struct {
ApplicationKey string `json:"ApplicationKey"`
}
+type S3Config struct {
+ BucketName string `json:"BucketName" validate:"required,min=1"`
+ Region string `json:"Region" validate:"required,min=1"`
+ Prefix string `json:"Prefix"`
+ Endpoint string `json:"Endpoint"`
+ UsePathStyle bool `json:"UsePathStyle"`
+ AccessKeyID string `json:"AccessKeyID"`
+ SecretAccessKey string `json:"SecretAccessKey"`
+}
+
func LoadConfig(path string, config *Config) error {
fileBytes, err := os.ReadFile(path)
if err != nil {