Add support for environment variables in configuration file
This commit is contained in:
@ -64,6 +64,9 @@ func readConfigurationFile(fileName string) (config *Config, err error) {
|
||||
}
|
||||
|
||||
func parseAndValidateConfigBytes(yamlBytes []byte) (config *Config, err error) {
|
||||
// Expand environment variables
|
||||
yamlBytes = []byte(os.ExpandEnv(string(yamlBytes)))
|
||||
// Parse configuration file
|
||||
err = yaml.Unmarshal(yamlBytes, &config)
|
||||
// Check if the configuration file at least has services.
|
||||
if config == nil || len(config.Services) == 0 {
|
||||
|
@ -13,12 +13,12 @@ services:
|
||||
url: https://twinnation.org/actuator/health
|
||||
interval: 15s
|
||||
conditions:
|
||||
- "$STATUS == 200"
|
||||
- "[STATUS] == 200"
|
||||
- name: github
|
||||
url: https://api.github.com/healthz
|
||||
conditions:
|
||||
- "$STATUS != 400"
|
||||
- "$STATUS != 500"
|
||||
- "[STATUS] != 400"
|
||||
- "[STATUS] != 500"
|
||||
`))
|
||||
if err != nil {
|
||||
t.Error("No error should've been returned")
|
||||
@ -53,7 +53,7 @@ services:
|
||||
- name: twinnation
|
||||
url: https://twinnation.org/actuator/health
|
||||
conditions:
|
||||
- "$STATUS == 200"
|
||||
- "[STATUS] == 200"
|
||||
`))
|
||||
if err != nil {
|
||||
t.Error("No error should've been returned")
|
||||
@ -76,7 +76,7 @@ services:
|
||||
- name: twinnation
|
||||
url: https://twinnation.org/actuator/health
|
||||
conditions:
|
||||
- "$STATUS == 200"
|
||||
- "[STATUS] == 200"
|
||||
`))
|
||||
if err != nil {
|
||||
t.Error("No error should've been returned")
|
||||
|
Reference in New Issue
Block a user