-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
env.go
72 lines (60 loc) · 2.47 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
67
68
69
70
71
72
package env
import (
"fmt"
"os"
"strings"
"github.com/smartcontractkit/chainlink/v2/core/store/models"
)
var (
Config = Var("CL_CONFIG")
DatabaseAllowSimplePasswords = Var("CL_DATABASE_ALLOW_SIMPLE_PASSWORDS")
DatabaseURL = Secret("CL_DATABASE_URL")
DatabaseBackupURL = Secret("CL_DATABASE_BACKUP_URL")
PasswordKeystore = Secret("CL_PASSWORD_KEYSTORE")
PasswordVRF = Secret("CL_PASSWORD_VRF")
PyroscopeAuthToken = Secret("CL_PYROSCOPE_AUTH_TOKEN")
PrometheusAuthToken = Secret("CL_PROMETHEUS_AUTH_TOKEN")
ThresholdKeyShare = Secret("CL_THRESHOLD_KEY_SHARE")
// Migrations env vars
EVMChainIDNotNullMigration0195 = "CL_EVM_CHAINID_NOT_NULL_MIGRATION_0195"
)
// LOOPP commands and vars
var (
MedianPlugin = NewPlugin("median")
MercuryPlugin = NewPlugin("mercury")
SolanaPlugin = NewPlugin("solana")
StarknetPlugin = NewPlugin("starknet")
// PrometheusDiscoveryHostName is the externally accessible hostname
// published by the node in the `/discovery` endpoint. Generally, it is expected to match
// the public hostname of node.
// Cluster step up like kubernetes may need to set this explicitly to ensure
// that Prometheus can discovery LOOPps.
// In house we observed that the resolved value of os.Hostname was not accessible to
// outside of the given pod
PrometheusDiscoveryHostName = Var("CL_PROMETHEUS_DISCOVERY_HOSTNAME")
// LOOPPHostName is the hostname used for HTTP communication between the
// node and LOOPps. In most cases this does not need to be set explicitly.
LOOPPHostName = Var("CL_LOOPP_HOSTNAME")
// Work around for Solana LOOPPs configured with zero values.
MinOCR2MaxDurationQuery = Var("CL_MIN_OCR2_MAX_DURATION_QUERY")
// PipelineOvertime is an undocumented escape hatch for overriding the default padding in pipeline executions.
PipelineOvertime = Var("CL_PIPELINE_OVERTIME")
)
type Var string
func (e Var) Get() string { return os.Getenv(string(e)) }
// Lookup wraps [os.LookupEnv]
func (e Var) Lookup() (string, bool) { return os.LookupEnv(string(e)) }
func (e Var) IsTrue() bool { return strings.ToLower(e.Get()) == "true" }
type Secret string
func (e Secret) Get() models.Secret { return models.Secret(os.Getenv(string(e))) }
type Plugin struct {
Cmd Var
Env Var
}
func NewPlugin(kind string) Plugin {
kind = strings.ToUpper(kind)
return Plugin{
Cmd: Var(fmt.Sprintf("CL_%s_CMD", kind)),
Env: Var(fmt.Sprintf("CL_%s_ENV", kind)),
}
}