diff --git a/README.md b/README.md index 776f307216cffbbf15643b5e7174c8edea91688f..ce2d75ef4aa0302c43c54cedbcf027b9e42396a9 100644 --- a/README.md +++ b/README.md @@ -42,13 +42,21 @@ buf generate ### Anwendung starten ``` -go run cmd/antragsraum-proxy/main.go +ACTIVE_PROFILE=local go run cmd/antragsraum-proxy/main.go ``` -## Config + + +## Config +config.yml is the default config for deployment [Config-Datei](./config/config.yml) +config-local.yml is the config file for local development +setting ACTIVE_PROFILE=local will load the config-local.yml + +[Config-Datei](./config/config-local.yml) + ``` http: server: @@ -63,6 +71,8 @@ logging: level: "ERROR" | "WARN" | "INFO" | "DEBUG" ``` + + ### Releasing Diese Schritte ausführen: diff --git a/internal/config/config.go b/internal/config/config.go index 5f32cec526799d894e7988b15cf1dc1cd42842b7..a21874c0e82210db33e4027512f8a297b33d8215 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -36,7 +36,7 @@ import ( const ( defaultConfig = "config.yml" testFilePath = "testdata/" - APP_ENV_NAME = "APP_ENV" + activeProfile = "ACTIVE_PROFILE" ) type Config struct { @@ -64,7 +64,7 @@ func LoadConfig(configFilePath ...string) Config { configFile := defaultConfig - env := os.Getenv(APP_ENV_NAME) + env := os.Getenv(activeProfile) if env != "" { configFile = fmt.Sprintf("config-%s.yml", env) } @@ -73,7 +73,7 @@ func LoadConfig(configFilePath ...string) Config { if len(configFilePath) > 0 { fp = configFilePath[0] - } else if testing.Testing() { + } else if testing.Testing() { fp = testFilePath+configFile } diff --git a/internal/config/config_test.go b/internal/config/config_test.go index 106bf2c0b900b64ce30d1eb155f105691b647e6c..f0877298897399ec976229c3adc3e8ab371a27b9 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -32,7 +32,7 @@ import ( ) func TestLoadConfig(t *testing.T) { - t.Run("should load default config from file", func(t *testing.T) { + t.Run("should load default config", func(t *testing.T) { config := LoadConfig() expectedConfig := Config{} @@ -46,12 +46,11 @@ func TestLoadConfig(t *testing.T) { }) t.Run("should load local config", func(t *testing.T) { - os.Setenv(APP_ENV_NAME, "local") - defer os.Unsetenv(APP_ENV_NAME) + assert.NoError(t, os.Setenv(activeProfile, "local"), "Setenv "+activeProfile+" should not return an error") config := LoadConfig() - assert.NoError(t, os.Unsetenv(APP_ENV_NAME), "Unsetenv "+APP_ENV_NAME+" should not return an error") + assert.NoError(t, os.Unsetenv(activeProfile), "Unsetenv "+activeProfile+" should not return an error") expectedConfig := Config{} expectedConfig.Grpc.Server.Mock = true diff --git a/internal/config/testdata/empty_test_config.yml b/internal/config/testdata/empty_test_config.yml deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000