Skip to content
Snippets Groups Projects
Commit 7d65af88 authored by OZGCloud's avatar OZGCloud
Browse files

OZG-6747 refactor config files

parent 900e69e9
No related branches found
No related tags found
No related merge requests found
File moved
File moved
...@@ -34,7 +34,7 @@ import ( ...@@ -34,7 +34,7 @@ import (
) )
const ( const (
defaultEnv = "development" defaultConfig = "config.yml"
testFilePath = "testdata/test_config.yml" testFilePath = "testdata/test_config.yml"
) )
...@@ -61,12 +61,14 @@ type Config struct { ...@@ -61,12 +61,14 @@ type Config struct {
func LoadConfig(configFilePath ...string) Config { func LoadConfig(configFilePath ...string) Config {
var config Config var config Config
configFile := defaultConfig
env := os.Getenv("APP_ENV") env := os.Getenv("APP_ENV")
if env == "" { if env != "" {
env = defaultEnv 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 { if len(configFilePath) > 0 {
fp = configFilePath[0] fp = configFilePath[0]
......
...@@ -59,7 +59,7 @@ spec: ...@@ -59,7 +59,7 @@ spec:
containers: containers:
- env: - env:
- name: APP_ENV - name: APP_ENV
value: "production" value: "{{ .Values.appEnv | default "dev" }}"
{{- with include "app.getCustomList" . }} {{- with include "app.getCustomList" . }}
{{ . | indent 10 }} {{ . | indent 10 }}
{{- end }} {{- end }}
......
...@@ -69,4 +69,13 @@ tests: ...@@ -69,4 +69,13 @@ tests:
path: spec.template.spec.containers[0].env path: spec.template.spec.containers[0].env
content: content:
name: APP_ENV name: APP_ENV
value: "production" value: "dev"
\ No newline at end of file - 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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment