forked from TykTechnologies/tyk-identity-broker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
47 lines (42 loc) · 1.06 KB
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package main
import (
"encoding/json"
"github.com/lonelycode/tyk-auth-proxy/tyk-api"
"io/ioutil"
)
var failCount int
// Configuration holds all configuration settings for TAP
type Configuration struct {
Secret string
Port int
ProfileDir string
BackEnd struct {
ProfileBackendSettings interface{}
IdentityBackendSettings interface{}
}
TykAPISettings tyk.TykAPI
HttpServerOptions struct {
UseSSL bool
CertFile string
KeyFile string
}
}
// loadConfig will load the config from a file
func loadConfig(filePath string, configStruct *Configuration) {
configuration, err := ioutil.ReadFile(filePath)
if err != nil {
log.Error("Couldn't load configuration file: ", err)
failCount += 1
if failCount < 3 {
loadConfig(filePath, configStruct)
} else {
log.Fatal("Could not open configuration, giving up.")
}
} else {
jsErr := json.Unmarshal(configuration, &configStruct)
if jsErr != nil {
log.Error("Couldn't unmarshal configuration: ", jsErr)
}
}
log.Debug("[MAIN] Settings Struct: ", configStruct.TykAPISettings)
}