diff options
author | kali kaneko (leap communications) <kali@leap.se> | 2021-11-23 20:43:12 +0100 |
---|---|---|
committer | kali kaneko (leap communications) <kali@leap.se> | 2021-11-23 21:51:28 +0100 |
commit | 28876566144cc74a32eb45f2fa4d966ebef8b0b2 (patch) | |
tree | ba662f984e685c53a46526b50d8fc560ce62fcc7 /pkg | |
parent | cdc80c3677753ad6eea8d864552077042bd9abb0 (diff) |
[pkg] allow multi-provider
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/backend/api.go | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/pkg/backend/api.go b/pkg/backend/api.go index dc7cbbf..8f36f1f 100644 --- a/pkg/backend/api.go +++ b/pkg/backend/api.go @@ -5,7 +5,9 @@ package backend import ( "C" "encoding/json" + "fmt" "log" + "os" "strconv" "strings" "unsafe" @@ -150,10 +152,20 @@ func InitOptsFromJSON(provider, providersJSON string) *InitOpts { if err != nil { log.Println("ERROR while parsing json:", err) } + var providerOpts *bitmask.ProviderOpts + providerOpts = &providers.Data[0] if len(providers.Data) != 1 { - panic("BUG: we do not support multi-provider yet") + chosenProvider := os.Getenv("LEAP_PROVIDER") + if chosenProvider != "" { + for _, p := range providers.Data { + if p.Provider == chosenProvider { + log.Println("Selecting provider: " + chosenProvider) + return &InitOpts{ProviderOptions: &p} + } + } + panic("BUG: unknown provider") + } } - providerOpts := &providers.Data[0] return &InitOpts{ProviderOptions: providerOpts} } |