Skip to content

Commit

Permalink
fixing output json, yaml tags
Browse files Browse the repository at this point in the history
  • Loading branch information
Yusuf Kanchwala committed Aug 13, 2020
1 parent 59203de commit 81cc9dd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pkg/policy/types.go
Expand Up @@ -12,5 +12,5 @@ type EngineInput struct {

// EngineOutput Contains data output from the engine
type EngineOutput struct {
*results.ViolationStore
*results.ViolationStore `json:"results" yaml:"results" xml:"results,attr"`
}
12 changes: 6 additions & 6 deletions pkg/results/types.go
Expand Up @@ -34,14 +34,14 @@ type Violation struct {

// ViolationStats Contains stats related to the violation data
type ViolationStats struct {
LowCount int `json:"low"`
MediumCount int `json:"medium"`
HighCount int `json:"high"`
TotalCount int `json:"total"`
LowCount int `json:"low" yaml:"low" xml:"low,attr"`
MediumCount int `json:"medium" yaml:"medium" xml:"medium,attr"`
HighCount int `json:"high" yaml:"high" xml:"high,attr"`
TotalCount int `json:"total" yaml:"total" xml:"total,attr"`
}

// ViolationStore Storage area for violation data
type ViolationStore struct {
Violations []*Violation `json:"violations"`
Count ViolationStats `json:"count"`
Violations []*Violation `json:"violations" yaml:"violations" xml:"violations,attr"`
Count ViolationStats `json:"count" yaml:"count" xml:"count,attr"`
}
7 changes: 6 additions & 1 deletion pkg/writer/xml.go
Expand Up @@ -21,6 +21,7 @@ import (
"io"

"github.com/accurics/terrascan/pkg/policy"
"go.uber.org/zap"
)

const (
Expand All @@ -33,7 +34,11 @@ func init() {

// XMLWriter prints data in XML format
func XMLWriter(data policy.EngineOutput, writer io.Writer) error {
j, _ := xml.MarshalIndent(data, "", " ")
j, err := xml.MarshalIndent(data, "", " ")
if err != nil {
zap.S().Errorf("failed to write XML output. error: '%v'", err)
return err
}
writer.Write(j)
writer.Write([]byte{'\n'})
return nil
Expand Down

0 comments on commit 81cc9dd

Please sign in to comment.