mirror of
https://github.com/prymitive/karma
synced 2026-05-05 03:16:51 +00:00
fix(backend): workaround viper map key parsing
This is a workaround until this issue is fixed upstream. Fixes #507
This commit is contained in:
@@ -3,6 +3,7 @@ package config
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -184,6 +185,28 @@ func (config *configSchema) Read() {
|
||||
log.Fatalf("Invalid grid.sorting.order value '%s', allowed options: disabled, startsAt, label", config.Grid.Sorting.Order)
|
||||
}
|
||||
|
||||
// FIXME workaround for https://github.com/prymitive/karma/issues/507
|
||||
// until https://github.com/spf13/viper/pull/635 is merged
|
||||
// read in raw config file if it's used and override maps where keys are label
|
||||
// names so we can't enforce parsed config key names
|
||||
if v.ConfigFileUsed() != "" {
|
||||
raw := configSchema{}
|
||||
|
||||
var rawConfigFile []byte
|
||||
rawConfigFile, err = ioutil.ReadFile(v.ConfigFileUsed())
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
err = yaml.Unmarshal(rawConfigFile, &raw)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
config.Labels.Color.Custom = raw.Labels.Color.Custom
|
||||
config.Grid.Sorting.CustomValues.Labels = raw.Grid.Sorting.CustomValues.Labels
|
||||
}
|
||||
|
||||
// accept single Alertmanager server from flag/env if nothing is set yet
|
||||
if len(config.Alertmanager.Servers) == 0 && v.GetString("alertmanager.uri") != "" {
|
||||
log.Info("Using simple config with a single Alertmanager server")
|
||||
|
||||
Reference in New Issue
Block a user