cascadeenv

package module
v0.0.0-...-caab472 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 12, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

README

CascadeEnv

init and checks os env for a list of names against ENV variables/ENV file/AWS ParamStore

Usage

In the import block: import "github.com/abbychau/cascadeenv"

In main:

//NewAWSSession makes an AWS session for dynamodb
func NewAWSSession() *session.Session {
	return session.Must(session.NewSessionWithOptions(session.Options{
		SharedConfigState: session.SharedConfigEnable,
	}))
}

func main() {
	log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr}) //Pretty logger for dev, can remove this line to use json-logger for production use

	log.Info().Msg("Booting...")
	err := cascadeenv.InitEnvVar(
		[]string{"HEALTH_CHECK_INTERVAL", "HEALTH_CHECK_MAX_CONSECUTIVE_ERROR", "SERVER_LISTEN", "USER_API_URL", "DB_USER", "DB_PASS", "DB_PROTOCOL", "DB_NAME"},
		".ENV",
		persistence.NewAWSSession(),
	)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExportEnvVar

func ExportEnvVar(names []string, types []reflect.Kind, envFilename string, session *session.Session) (map[string]interface{}, error)

ExportEnvVar init and checks os env for a list of names against ENV variables/ENV file/AWS ParamStore and exports to a map

func InitEnvVar

func InitEnvVar(names []string, envFilename string, session *session.Session) error

InitEnvVar init and checks os env for a list of names against ENV variables/ENV file/AWS ParamStore

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL