Documentation
¶
Index ¶
- func Get(key string) (string, error)
- func Init(prodCheck IsProductionEnviroment) error
- func IsDevelopment() bool
- func IsProduction() bool
- func SetDevelopmentLoader(loader Loader)
- func SetProductionLoader(loader Loader)
- func SetRequiredVariables(vars []string)
- type DotEnvLoader
- type EnvLoader
- type GCEMetadataLoader
- type IsProductionEnviroment
- type Loader
- type Type
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Init ¶
func Init(prodCheck IsProductionEnviroment) error
Init the enviroment based on whether or not we are in production or not.
func IsDevelopment ¶
func IsDevelopment() bool
IsDevelopment returns whether or not we are in a development enviroment.
func IsProduction ¶
func IsProduction() bool
IsProduction returns whether or not we are in a production enviroment.
func SetDevelopmentLoader ¶
func SetDevelopmentLoader(loader Loader)
SetDevelopmentLoader setss an enviroment variable loader for the development enviroment. If the enviroment is development, this loader will be used.
func SetProductionLoader ¶
func SetProductionLoader(loader Loader)
SetProductionLoader sets an enviroment variable loader for the production enviroment. If the enviroment is production, this loader will be used.
func SetRequiredVariables ¶
func SetRequiredVariables(vars []string)
SetRequiredVariables stores an array of required enviroment variables for optimal execution. This is used as a check upon initialization to ensure that the enviroment has all required variables.
Types ¶
type DotEnvLoader ¶
type DotEnvLoader struct{}
DotEnvLoader loads enviroment variables from a .env file.
func (*DotEnvLoader) Get ¶
func (de *DotEnvLoader) Get(key string) (string, error)
Get an enviroment variable from the users enviroment. Note that the dotenv loader will load any variables from the .env file to the enviroment.
func (*DotEnvLoader) Init ¶
func (de *DotEnvLoader) Init() error
Init an DotEnvLoader which loads the enviroment variables in the .env file to the os enviroment.
type EnvLoader ¶
type EnvLoader struct{}
EnvLoader loads enviroment variable from the users enviroment. This loader is best used in a development enviroment, where developers can put required enviroment variables in their ~/.bashrc or ~/.zshrc files.
type GCEMetadataLoader ¶
type GCEMetadataLoader struct{}
GCEMetadataLoader is used to load enviromental data from the GCE project attribute keys. Note that this will only work if we are on a GCE instance.
func (*GCEMetadataLoader) Get ¶
func (gce *GCEMetadataLoader) Get(key string) (string, error)
Get a key from the GCE Metadata server.
func (*GCEMetadataLoader) Init ¶
func (gce *GCEMetadataLoader) Init() error
Init the GCEMetadataLoader. This function checks that we are indeed on a google compute engine instance.
type IsProductionEnviroment ¶
type IsProductionEnviroment func() bool
IsProductionEnviroment defines logic for checking if we are in production.