aboutsummaryrefslogtreecommitdiffstats
path: root/internal/configloader
diff options
context:
space:
mode:
authorEugene Triguba <eugenetriguba@gmail.com>2024-03-14 20:00:09 -0400
committerEugene Triguba <eugenetriguba@gmail.com>2024-03-14 20:00:09 -0400
commit75e6e9a2996ab5186f29f64eda2850b49da0ad93 (patch)
treee3f5886d0450ee68b8f25d8a3c62325382cf8d63 /internal/configloader
parentUse p 1 for github workflow (diff)
downloadcli-75e6e9a2996ab5186f29f64eda2850b49da0ad93.zip
Update env var names
Diffstat (limited to 'internal/configloader')
-rw-r--r--internal/configloader/configloader.go14
-rw-r--r--internal/configloader/configloader_test.go36
2 files changed, 25 insertions, 25 deletions
diff --git a/internal/configloader/configloader.go b/internal/configloader/configloader.go
index 4fbe27f..eed150f 100644
--- a/internal/configloader/configloader.go
+++ b/internal/configloader/configloader.go
@@ -45,7 +45,7 @@ type Config struct {
// Information related to how to connect to the database
// that is desired to run migrations against.
- Connection ConnectionConfig `toml:"connection"`
+ Connection ConnectionConfig `toml:"database"`
}
type MigrationsConfig struct {
@@ -54,12 +54,12 @@ type MigrationsConfig struct {
}
type ConnectionConfig struct {
- Host string `toml:"host" envconfig:"BOLT_DB_CONN_HOST"`
- Port string `toml:"port" envconfig:"BOLT_DB_CONN_PORT"`
- User string `toml:"user" envconfig:"BOLT_DB_CONN_USER"`
- Password string `toml:"password" envconfig:"BOLT_DB_CONN_PASSWORD"`
- DBName string `toml:"dbname" envconfig:"BOLT_DB_CONN_DBNAME"`
- Driver string `toml:"driver" envconfig:"BOLT_DB_CONN_DRIVER"`
+ Host string `toml:"host" envconfig:"BOLT_DB_HOST"`
+ Port string `toml:"port" envconfig:"BOLT_DB_PORT"`
+ User string `toml:"user" envconfig:"BOLT_DB_USER"`
+ Password string `toml:"password" envconfig:"BOLT_DB_PASSWORD"`
+ DBName string `toml:"dbname" envconfig:"BOLT_DB_NAME"`
+ Driver string `toml:"driver" envconfig:"BOLT_DB_DRIVER"`
}
func NewConfig() (*Config, error) {
diff --git a/internal/configloader/configloader_test.go b/internal/configloader/configloader_test.go
index 22fdd26..7684436 100644
--- a/internal/configloader/configloader_test.go
+++ b/internal/configloader/configloader_test.go
@@ -35,12 +35,12 @@ func TestNewConfigWithInvalidVersionStyle(t *testing.T) {
}
func TestNewConfigFindsFileAndPopulatesConfigStruct(t *testing.T) {
- bolttest.UnsetEnv(t, "BOLT_DB_CONN_HOST")
- bolttest.UnsetEnv(t, "BOLT_DB_CONN_PORT")
- bolttest.UnsetEnv(t, "BOLT_DB_CONN_USER")
- bolttest.UnsetEnv(t, "BOLT_DB_CONN_PASSWORD")
- bolttest.UnsetEnv(t, "BOLT_DB_CONN_DBNAME")
- bolttest.UnsetEnv(t, "BOLT_DB_CONN_DRIVER")
+ bolttest.UnsetEnv(t, "BOLT_DB_HOST")
+ bolttest.UnsetEnv(t, "BOLT_DB_PORT")
+ bolttest.UnsetEnv(t, "BOLT_DB_USER")
+ bolttest.UnsetEnv(t, "BOLT_DB_PASSWORD")
+ bolttest.UnsetEnv(t, "BOLT_DB_NAME")
+ bolttest.UnsetEnv(t, "BOLT_DB_DRIVER")
bolttest.UnsetEnv(t, "BOLT_MIGRATIONS_DIR_PATH")
bolttest.UnsetEnv(t, "BOLT_MIGRATIONS_VERSION_STYLE")
expectedCfg := configloader.Config{
@@ -100,12 +100,12 @@ func TestNewConfigCanBeOverridenByEnvVars(t *testing.T) {
}
t.Setenv("BOLT_MIGRATIONS_VERSION_STYLE", string(envCfg.Migrations.VersionStyle))
t.Setenv("BOLT_MIGRATIONS_DIR_PATH", envCfg.Migrations.DirectoryPath)
- t.Setenv("BOLT_DB_CONN_HOST", envCfg.Connection.Host)
- t.Setenv("BOLT_DB_CONN_PORT", envCfg.Connection.Port)
- t.Setenv("BOLT_DB_CONN_USER", envCfg.Connection.User)
- t.Setenv("BOLT_DB_CONN_PASSWORD", envCfg.Connection.Password)
- t.Setenv("BOLT_DB_CONN_DBNAME", envCfg.Connection.DBName)
- t.Setenv("BOLT_DB_CONN_DRIVER", envCfg.Connection.Driver)
+ t.Setenv("BOLT_DB_HOST", envCfg.Connection.Host)
+ t.Setenv("BOLT_DB_PORT", envCfg.Connection.Port)
+ t.Setenv("BOLT_DB_USER", envCfg.Connection.User)
+ t.Setenv("BOLT_DB_PASSWORD", envCfg.Connection.Password)
+ t.Setenv("BOLT_DB_NAME", envCfg.Connection.DBName)
+ t.Setenv("BOLT_DB_DRIVER", envCfg.Connection.Driver)
cfg, err := configloader.NewConfig()
assert.Nil(t, err)
@@ -113,12 +113,12 @@ func TestNewConfigCanBeOverridenByEnvVars(t *testing.T) {
}
func TestNewConfigSearchesParentDirectories(t *testing.T) {
- bolttest.UnsetEnv(t, "BOLT_DB_CONN_HOST")
- bolttest.UnsetEnv(t, "BOLT_DB_CONN_PORT")
- bolttest.UnsetEnv(t, "BOLT_DB_CONN_USER")
- bolttest.UnsetEnv(t, "BOLT_DB_CONN_PASSWORD")
- bolttest.UnsetEnv(t, "BOLT_DB_CONN_DBNAME")
- bolttest.UnsetEnv(t, "BOLT_DB_CONN_DRIVER")
+ bolttest.UnsetEnv(t, "BOLT_DB_HOST")
+ bolttest.UnsetEnv(t, "BOLT_DB_PORT")
+ bolttest.UnsetEnv(t, "BOLT_DB_USER")
+ bolttest.UnsetEnv(t, "BOLT_DB_PASSWORD")
+ bolttest.UnsetEnv(t, "BOLT_DB_NAME")
+ bolttest.UnsetEnv(t, "BOLT_DB_DRIVER")
bolttest.UnsetEnv(t, "BOLT_MIGRATIONS_DIR_PATH")
bolttest.UnsetEnv(t, "BOLT_MIGRATIONS_VERSION_STYLE")
expectedCfg := configloader.Config{