diff --git a/config/config-development.yml b/config/config-local.yml similarity index 100% rename from config/config-development.yml rename to config/config-local.yml diff --git a/config/config-production.yml b/config/config.yml similarity index 100% rename from config/config-production.yml rename to config/config.yml diff --git a/internal/config/config.go b/internal/config/config.go index 52be8d2340c3d1f55bf21cbf3cede7d5f0d045ed..b49a4241d3b9d8e44eaaa52d465ef54d7e46a9e2 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -34,7 +34,7 @@ import ( ) const ( - defaultEnv = "development" + defaultConfig = "config.yml" testFilePath = "testdata/test_config.yml" ) @@ -61,12 +61,14 @@ type Config struct { func LoadConfig(configFilePath ...string) Config { var config Config + configFile := defaultConfig + env := os.Getenv("APP_ENV") - if env == "" { - env = defaultEnv + if env != "" { + configFile = fmt.Sprintf("config-%s.yml", env) } - fp := fmt.Sprintf("config/config-%s.yml", env) + fp := fmt.Sprintf("config/%s", configFile) if len(configFilePath) > 0 { fp = configFilePath[0] diff --git a/src/main/helm/templates/deployment.yaml b/src/main/helm/templates/deployment.yaml index 31ce8ed688cfc60a3b0ea6b698d8ce9500a23fbe..687f78a569b7c20a67dc3433af0cd6195c0dbfcd 100644 --- a/src/main/helm/templates/deployment.yaml +++ b/src/main/helm/templates/deployment.yaml @@ -59,7 +59,7 @@ spec: containers: - env: - name: APP_ENV - value: "production" + value: "{{ .Values.appEnv | default "dev" }}" {{- with include "app.getCustomList" . }} {{ . | indent 10 }} {{- end }} diff --git a/src/test/helm/deployment_env_test.yaml b/src/test/helm/deployment_env_test.yaml index d7a973acebddb31340c3503ff84987498fa293bd..8223aac295dd095d9793bf0180bab8aa203a9428 100644 --- a/src/test/helm/deployment_env_test.yaml +++ b/src/test/helm/deployment_env_test.yaml @@ -69,4 +69,13 @@ tests: path: spec.template.spec.containers[0].env content: name: APP_ENV - value: "production" \ No newline at end of file + value: "dev" + - it: should set APP_ENV + set: + appEnv: prod + asserts: + - contains: + path: spec.template.spec.containers[0].env + content: + name: APP_ENV + value: "prod" \ No newline at end of file