package pilgrim_conf import "os" const ( EnvVarKey_Url string = "PILGRIM_URL" EnvVarKey_Driver = "PILGRIM_DRIVER" EnvVarKey_Username = "PILGRIM_USERNAME" EnvVarKey_Password = "PILGRIM_PASSWORD" EnvVarKey_Host = "PILGRIM_HOST" EnvVarKey_Port = "PILGRIM_PORT" EnvVarKey_Segments = "PILGRIM_SEGMENTS" EnvVarKey_Arguments = "PILGRIM_ARGUMENTS" EnvVarKey_Directory = "PILGRIM_DIRECTORY" EnvVarKey_Schema = "PILGRIM_SCHEMA" EnvVarKey_Table = "PILGRIM_TABLE" ) type EnvVarRetriever interface { Url() (value string, isDefined bool) Driver() (value DbDriver, isDefined bool) Username() (value string, isDefined bool) Password() (value string, isDefined bool) Host() (value string, isDefined bool) Port() (value string, isDefined bool) Segments() (value []string, isDefined bool) Args() (value map[string]string, isDefined bool) Directory() (value string, isDefined bool) MigrationTable() (value string, isDefined bool) MigrationTableSchema() (value string, isDefined bool) } type envVarContext struct { } func NewEnvVarContext() *envVarContext { return &envVarContext{} } func (ec *envVarContext) Url() (value string, isDefined bool) { return os.LookupEnv(EnvVarKey_Url) } func (ec *envVarContext) Driver() (value DbDriver, isDefined bool) { val, provided := os.LookupEnv(EnvVarKey_Driver) return DbDriver(val), provided } func (ec *envVarContext) Username() (value string, isDefined bool) { return os.LookupEnv(EnvVarKey_Username) } func (ec *envVarContext) Password() (value string, isDefined bool) { return os.LookupEnv(EnvVarKey_Password) } func (ec *envVarContext) Host() (value string, isDefined bool) { return os.LookupEnv(EnvVarKey_Host) } func (ec *envVarContext) Port() (value string, isDefined bool) { return os.LookupEnv(EnvVarKey_Port) } func (ec *envVarContext) Segments() (value []string, isDefined bool) { rawVal, provided := os.LookupEnv(EnvVarKey_Segments) if !provided { return []string{}, false } return ParseSegments(rawVal), true } func (ec *envVarContext) Args() (value map[string]string, isDefined bool) { rawVal, provided := os.LookupEnv(EnvVarKey_Arguments) if !provided { return make(map[string]string), false } return ParseArguments(rawVal), true } func (ec *envVarContext) Directory() (value string, isDefined bool) { return os.LookupEnv(EnvVarKey_Directory) } func (ec *envVarContext) MigrationTable() (value string, isDefined bool) { return os.LookupEnv(EnvVarKey_Table) } func (ec *envVarContext) MigrationTableSchema() (value string, isDefined bool) { return os.LookupEnv(EnvVarKey_Schema) }