Parse environment variables in OpenTracing configuration

This commit is contained in:
Sebastiaan Tammer 2019-02-10 16:59:05 +01:00
parent 5c4854b537
commit fc5e99a151
2 changed files with 17 additions and 11 deletions

View file

@ -954,7 +954,7 @@ func createOpentracingCfg(cfg ngx_config.Configuration) error {
return err
}
} else if cfg.JaegerCollectorHost != "" {
tmpl, err = template.New("jarger").Parse(jaegerTmpl)
tmpl, err = template.New("jaeger").Parse(jaegerTmpl)
if err != nil {
return err
}
@ -968,7 +968,10 @@ func createOpentracingCfg(cfg ngx_config.Configuration) error {
return err
}
return ioutil.WriteFile("/etc/nginx/opentracing.json", tmplBuf.Bytes(), file.ReadWriteByUser)
// Expand possible environment variables before writing the configuration to file.
expanded := os.ExpandEnv(string(tmplBuf.Bytes()))
return ioutil.WriteFile("/etc/nginx/opentracing.json", []byte(expanded), file.ReadWriteByUser)
}
func cleanTempNginxCfg() error {