Fix configuration for prometheus address (#2763)

The env variable for prometheus address is not respected as it should be set as
viper default config.

Ticket: https://mattermost.atlassian.net/browse/43295
This commit is contained in:
Spiros Economakis 2022-04-13 00:43:29 +03:00 committed by GitHub
parent af35a8e2c2
commit 539aee6a46
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 14 deletions

View file

@ -10,7 +10,7 @@
"filesdriver": "local",
"filespath": "./files",
"telemetry": true,
"prometheus_address": ":9092",
"prometheusaddress": ":9092",
"webhook_update": [],
"session_expire_time": 2592000,
"session_refresh_time": 18000,

View file

@ -8,7 +8,7 @@
"webpath": "./pack",
"filespath": "./files",
"telemetry": true,
"prometheus_address": ":9092",
"prometheusaddress": ":9092",
"session_expire_time": 2592000,
"session_refresh_time": 18000,
"localOnly": false,

View file

@ -8,7 +8,7 @@
"webpath": "./pack",
"filespath": "./files",
"telemetry": true,
"prometheus_address": ":9092",
"prometheusaddress": ":9092",
"session_expire_time": 2592000,
"session_refresh_time": 18000,
"localOnly": false,

View file

@ -40,7 +40,7 @@ type Configuration struct {
MaxFileSize int64 `json:"maxfilesize" mapstructure:"mafilesize"`
Telemetry bool `json:"telemetry" mapstructure:"telemetry"`
TelemetryID string `json:"telemetryid" mapstructure:"telemetryid"`
PrometheusAddress string `json:"prometheus_address" mapstructure:"prometheus_address"`
PrometheusAddress string `json:"prometheusaddress" mapstructure:"prometheusaddress"`
WebhookUpdate []string `json:"webhook_update" mapstructure:"webhook_update"`
Secret string `json:"secret" mapstructure:"secret"`
SessionExpireTime int64 `json:"session_expire_time" mapstructure:"session_expire_time"`
@ -95,6 +95,7 @@ func ReadConfigFile(configFilePath string) (*Configuration, error) {
viper.SetDefault("AuthMode", "native")
viper.SetDefault("NotifyFreqCardSeconds", 120) // 2 minutes after last card edit
viper.SetDefault("NotifyFreqBoardSeconds", 86400) // 1 day after last card edit
viper.SetDefault("PrometheusAddress", "")
err := viper.ReadInConfig() // Find and read the config file
if err != nil { // Handle errors reading the config file