-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
34 lines (28 loc) · 794 Bytes
/
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
package oauth
import (
"errors"
"os"
)
const ClientIdEnv = "GITHUBOAUTH_CLIENTID"
const ClientSecretEnv = "GITHUBOAUTH_CLIENTSECRET"
var (
clientId string = "set_by_init"
clientSecret string = "set_by_init"
)
func ReadConfig() (err error) {
clientId, clientSecret, err = loadOAuthConfig()
return err
}
func loadOAuthConfig() (clientId string, clientSecret string, err error) {
clientId, found := os.LookupEnv(ClientIdEnv)
if !found {
err = errors.New("service host to generate documents is not configured. Expect environment variable " + ClientIdEnv)
return
}
clientSecret, found = os.LookupEnv(ClientSecretEnv)
if !found {
err = errors.New("service port to generate documents is not configured. Expect environment variable " + ClientSecretEnv)
return
}
return
}