Skip to content

Commit

Permalink
Rename Env -> Var; EnvSecret -> Secret
Browse files Browse the repository at this point in the history
  • Loading branch information
cedric-cordenier committed Jul 10, 2023
1 parent 34d161b commit 5051c75
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions core/config/env/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,45 +8,45 @@ import (
)

var (
Config = Env("CL_CONFIG")
Config = Var("CL_CONFIG")

// LOOPP commands and vars
MedianPluginCmd = Env("CL_MEDIAN_CMD")
SolanaPluginCmd = Env("CL_SOLANA_CMD")
StarknetPluginCmd = Env("CL_STARKNET_CMD")
MedianPluginCmd = Var("CL_MEDIAN_CMD")
SolanaPluginCmd = Var("CL_SOLANA_CMD")
StarknetPluginCmd = Var("CL_STARKNET_CMD")
// 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 = Env("CL_PROMETHEUS_DISCOVERY_HOSTNAME")
PrometheusDiscoveryHostName = Var("CL_PROMETHEUS_DISCOVERY_HOSTNAME")
// EnvLooopHostName is the hostname used for HTTP communication between the
// node and LOOPps. In most cases this does not need to be set explicitly.
LooppHostName = Env("CL_LOOPP_HOSTNAME")

DatabaseAllowSimplePasswords = Env("CL_DATABASE_ALLOW_SIMPLE_PASSWORDS")
DatabaseURL = EnvSecret("CL_DATABASE_URL")
DatabaseBackupURL = EnvSecret("CL_DATABASE_BACKUP_URL")
ExplorerAccessKey = EnvSecret("CL_EXPLORER_ACCESS_KEY")
ExplorerSecret = EnvSecret("CL_EXPLORER_SECRET")
PasswordKeystore = EnvSecret("CL_PASSWORD_KEYSTORE")
PasswordVRF = EnvSecret("CL_PASSWORD_VRF")
PyroscopeAuthToken = EnvSecret("CL_PYROSCOPE_AUTH_TOKEN")
PrometheusAuthToken = EnvSecret("CL_PROMETHEUS_AUTH_TOKEN")
ThresholdKeyShare = EnvSecret("CL_THRESHOLD_KEY_SHARE")
LooppHostName = Var("CL_LOOPP_HOSTNAME")

DatabaseAllowSimplePasswords = Var("CL_DATABASE_ALLOW_SIMPLE_PASSWORDS")
DatabaseURL = Secret("CL_DATABASE_URL")
DatabaseBackupURL = Secret("CL_DATABASE_BACKUP_URL")
ExplorerAccessKey = Secret("CL_EXPLORER_ACCESS_KEY")
ExplorerSecret = Secret("CL_EXPLORER_SECRET")
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")
)

type Env string
type Var string

func (e Env) Get() string { return os.Getenv(string(e)) }
func (e Var) Get() string { return os.Getenv(string(e)) }

// Lookup wraps [os.LookupEnv]
func (e Env) Lookup() (string, bool) { return os.LookupEnv(string(e)) }
func (e Var) Lookup() (string, bool) { return os.LookupEnv(string(e)) }

func (e Env) IsTrue() bool { return strings.ToLower(e.Get()) == "true" }
func (e Var) IsTrue() bool { return strings.ToLower(e.Get()) == "true" }

type EnvSecret string
type Secret string

func (e EnvSecret) Get() models.Secret { return models.Secret(os.Getenv(string(e))) }
func (e Secret) Get() models.Secret { return models.Secret(os.Getenv(string(e))) }

0 comments on commit 5051c75

Please sign in to comment.