Skip to content

Commit

Permalink
fix panic when customfields map wasn't init
Browse files Browse the repository at this point in the history
  • Loading branch information
Issif committed Jun 13, 2019
1 parent 4d77746 commit 6c71139
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion config.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
)

func getConfig() *types.Configuration {
c := &types.Configuration{Customfields: make(map[string]interface{})}
c := &types.Configuration{Customfields: make(map[string]string)}

configFile := kingpin.Flag("config-file", "config file").Short('c').ExistingFile()
kingpin.Parse()
Expand Down
6 changes: 5 additions & 1 deletion handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package main

import (
"bytes"
"strconv"
"encoding/json"
"log"
"net/http"
"strconv"
// "strconv"
"strings"
"time"

Expand Down Expand Up @@ -48,6 +49,9 @@ func mainHandler(w http.ResponseWriter, r *http.Request) {

// falcopayload.OutputFields = make(map[string]interface{})
if len(config.Customfields) > 0 {
if falcopayload.OutputFields == nil {
falcopayload.OutputFields = make(map[string]interface{})
}
for key, value := range config.Customfields {
falcopayload.OutputFields[key] = value
}
Expand Down
2 changes: 1 addition & 1 deletion types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type Configuration struct {
Alertmanager alertmanagerOutputConfig
Elasticsearch elasticsearchOutputConfig
Influxdb InfluxdbOutputConfig
Customfields map[string]interface{}
Customfields map[string]string
}

type slackOutputConfig struct {
Expand Down

0 comments on commit 6c71139

Please sign in to comment.