Skip to content

Commit

Permalink
fix json formatting (#114)
Browse files Browse the repository at this point in the history
  • Loading branch information
tbauriedel authored Feb 14, 2024
1 parent f7d297a commit f2f7709
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 14 deletions.
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

0 comments on commit f2f7709

Please sign in to comment.