-
Notifications
You must be signed in to change notification settings - Fork 43
/
env.go
66 lines (56 loc) · 1.45 KB
/
env.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package env
import (
syslog "log"
"os"
"strings"
)
const (
SpaceWorkingDir = "SPACE_APP_DIR"
LogLevel = "LOG_LEVEL"
IpfsAddr = "IPFS_ADDR"
IpfsNode = "IPFS_NODE"
IpfsNodeAddr = "IPFS_NODE_ADDR"
IpfsNodePath = "IPFS_NODE_PATH"
ServicesAPIURL = "SERVICES_API_URL"
VaultAPIURL = "VAULT_API_URL"
VaultSaltSecret = "VAULT_SALT_SECRET"
ServicesHubAuthURL = "SERVICES_HUB_AUTH_URL"
SpaceStorageSiteUrl = "SPACE_STORAGE_SITE_URL"
TextileHubTarget = "TXL_HUB_TARGET"
TextileHubMa = "TXL_HUB_MA"
TextileThreadsTarget = "TXL_THREADS_TARGET"
TextileHubGatewayUrl = "TXL_HUB_GATEWAY_URL"
TextileUserKey = "TXL_USER_KEY"
TextileUserSecret = "TXL_USER_SECRET"
)
type SpaceEnv interface {
CurrentFolder() (string, error)
WorkingFolder() string
LogLevel() string
}
type defaultEnv struct {
}
func (d defaultEnv) CurrentFolder() (string, error) {
path, err := os.Executable()
if err != nil {
return "", err
}
pathSegments := strings.Split(path, "/")
wd := strings.Join(pathSegments[:len(pathSegments)-1], "/")
return wd, nil
}
func (d defaultEnv) WorkingFolder() string {
cf, err := d.CurrentFolder()
if err != nil {
syslog.Fatal("unable to get working folder", err)
panic(err)
}
return cf
}
func (d defaultEnv) LogLevel() string {
return "Info"
}
// TODO: use this one after figuring textile keys
func NewDefault() SpaceEnv {
return defaultEnv{}
}