summaryrefslogtreecommitdiff
path: root/pkg/backend/api.go
diff options
context:
space:
mode:
authorkali kaneko (leap communications) <kali@leap.se>2021-11-23 20:43:12 +0100
committerkali kaneko (leap communications) <kali@leap.se>2021-11-23 21:51:28 +0100
commit28876566144cc74a32eb45f2fa4d966ebef8b0b2 (patch)
treeba662f984e685c53a46526b50d8fc560ce62fcc7 /pkg/backend/api.go
parentcdc80c3677753ad6eea8d864552077042bd9abb0 (diff)
[pkg] allow multi-provider
Diffstat (limited to 'pkg/backend/api.go')
-rw-r--r--pkg/backend/api.go16
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}
}