File tree Expand file tree Collapse file tree 1 file changed +20
-3
lines changed
Expand file tree Collapse file tree 1 file changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,11 @@ package main
22
33import (
44 "encoding/json"
5+ "fmt"
6+ "io"
7+ "net/http"
58 "os"
9+ "strings"
610)
711
812type BackupProviderConfigType string
@@ -107,12 +111,25 @@ func ConvertToBackupProviderConfig[T any](raw any) (*T, error) {
107111}
108112
109113func LoadConfig (path string ) (* SyncConfig , error ) {
110- file , err := os .ReadFile (path )
114+ var body []byte
115+ var err error
116+
117+ if strings .HasPrefix (path , "http" ) {
118+ resp , httpErr := http .Get (path )
119+ if httpErr != nil {
120+ return nil , fmt .Errorf ("failed to fetch config: %w" , httpErr )
121+ }
122+ defer resp .Body .Close ()
123+ body , err = io .ReadAll (resp .Body )
124+ } else {
125+ body , err = os .ReadFile (path )
126+ }
127+
111128 if err != nil {
112- return nil , err
129+ return nil , fmt . Errorf ( "failed to read config: %w" , err )
113130 }
114131 var conf SyncConfig
115- err = json .Unmarshal (file , & conf )
132+ err = json .Unmarshal (body , & conf )
116133 if err != nil {
117134 return nil , err
118135 }
You can’t perform that action at this time.
0 commit comments