Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 2 additions & 13 deletions internal/collection/collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package collection
import (
"archive/zip"
"bytes"
"encoding/json"
"fmt"
"io"
"strings"
Expand Down Expand Up @@ -141,18 +140,8 @@ func (c *Collection) AddFileYAML(fileName string, data interface{}) {
_ = c.AddFileToOutput(file)
}

func (c *Collection) AddFileJSON(fileName string, data interface{}) {
var buf bytes.Buffer

err := json.NewEncoder(&buf).Encode(&data)
if err != nil {
c.Log.Debugf("could not encode JSON data for '%s': %s", fileName, err)
}

file := NewFile(fileName)
file.Data = buf.Bytes()

_ = c.AddFileToOutput(file)
func (c *Collection) AddFileJSON(fileName string, data []byte) {
c.AddFileDataRaw(fileName, data)
}

func (c *Collection) AddFiles(prefix, source string) {
Expand Down
2 changes: 1 addition & 1 deletion modules/icinga2/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func collectStatus(endpoint string, c *collection.Collection) error {
}

// add body to file
c.AddFileJSON(filepath.Join(ModuleName, fmt.Sprintf("api-v1_status_%s.json", extractHostname(endpoint))), string(body))
c.AddFileJSON(filepath.Join(ModuleName, fmt.Sprintf("api-v1_status_%s.json", extractHostname(endpoint))), body)

return nil
}
Expand Down