Skip to content

Commit da1fffc

Browse files
committed
feat: Add support for WASM compilation
1 parent e02aa17 commit da1fffc

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

ovh/configuration.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"fmt"
77
"os"
88
"os/user"
9+
"runtime"
910
"strings"
1011

1112
"golang.org/x/oauth2/clientcredentials"
@@ -66,6 +67,12 @@ func expandConfigPaths() []interface{} {
6667
// loadINI builds a ini.File from the configuration paths provided in configPaths.
6768
// It's a helper for loadConfig.
6869
func loadINI() (*ini.File, error) {
70+
// Don't try to load configuration from the
71+
// filesystem when compiling for WebAssembly
72+
if runtime.GOARCH == "wasm" && runtime.GOOS == "js" {
73+
return ini.Empty(), nil
74+
}
75+
6976
paths := expandConfigPaths()
7077
if len(paths) == 0 {
7178
return ini.Empty(), nil
@@ -195,12 +202,20 @@ func getConfigValue(cfg *ini.File, section, name, def string) string {
195202
return fromEnv
196203
}
197204

205+
if !cfg.HasSection(section) {
206+
return def
207+
}
208+
198209
// Attempt to load from configuration
199210
fromSection := cfg.Section(section)
200211
if fromSection == nil {
201212
return def
202213
}
203214

215+
if !fromSection.HasKey(name) {
216+
return def
217+
}
218+
204219
fromSectionKey := fromSection.Key(name)
205220
if fromSectionKey == nil {
206221
return def

0 commit comments

Comments
 (0)