Skip to content

Commit

Permalink
Remove backward compatibility (Fixes camptocamp#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcanevet committed Mar 24, 2018
1 parent cefc1c8 commit b2b849c
Showing 1 changed file with 4 additions and 19 deletions.
23 changes: 4 additions & 19 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ type Config struct {
}

type Node struct {
Certname string `json:"certname"`
Exporters map[string]interface{} `json:"value"`
Certname string `json:"certname"`
Exporters map[string][]string `json:"value"`
}

type StaticConfig struct {
Expand Down Expand Up @@ -133,23 +133,8 @@ func getTargets() (c []byte, err error) {

for _, node := range nodes {
for jobName, targets := range node.Exporters {
var t []string

switch v := targets.(type) {
case string:
log.Warningf("Deprecated: target should be an Array not a String: %v", v)
t = []string{v}
case []interface{}:
t = make([]string, len(v))
for i := range v {
t[i] = v[i].(string)
}
default:
log.Errorf("failed to determine kind of targets: %v", err)
}

for i := range t {
url, err := url.Parse(t[i])
for i := range targets {
url, err := url.Parse(targets[i])
if err != nil {
return nil, err
}
Expand Down

0 comments on commit b2b849c

Please sign in to comment.