-
Notifications
You must be signed in to change notification settings - Fork 12
/
env_config.go
42 lines (34 loc) · 1.07 KB
/
env_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
package config
import (
"fmt"
"github.com/kelseyhightower/envconfig"
)
// RedisEnvConfig contains all config for redis
type RedisEnvConfig struct {
Password string `envconfig:"REDIS_PWD" default:""`
}
// EthEnvConfig contains all config for ethereum / ethereum like (EVM) networks
type EthEnvConfig struct {
RPCURL string `envconfig:"MB_RPC_URL"`
PrivateKey string `envconfig:"MB_PRIVATE_KEY"`
KeystorePath string `envconfig:"MB_KEYSTORE_PATH"`
KeyStorePwd string `envconfig:"MB_KEYSTORE_PWD"`
}
// IpfsEnvConfig contains all config for IPFS pinning services
type IpfsEnvConfig struct {
IpfsPinnerServer string `envconfig:"IFPS_PINNER_SERVER" default:"http://127.0.0.1:3000"`
}
// EnvConfig composes all configs into a single env config for the bsp-agent node
type EnvConfig struct {
IpfsConfig IpfsEnvConfig
RedisConfig RedisEnvConfig
EthConfig EthEnvConfig
}
func loadEnvConfig() (*EnvConfig, error) {
cfg := &EnvConfig{}
err := envconfig.Process("", cfg)
if err != nil {
return nil, fmt.Errorf("unable to parse configuration: %w", err)
}
return cfg, nil
}