mirror of
https://github.com/aquasecurity/trivy.git
synced 2025-12-22 07:10:41 -08:00
BREAKING(report): migrate to new json schema (#1265)
This commit is contained in:
@@ -4,11 +4,8 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
"github.com/aquasecurity/trivy/pkg/log"
|
||||
)
|
||||
|
||||
// JSONWriter implements result Writer
|
||||
@@ -18,15 +15,7 @@ type JSONWriter struct {
|
||||
|
||||
// Write writes the results in JSON format
|
||||
func (jw JSONWriter) Write(report Report) error {
|
||||
var v interface{} = report
|
||||
if os.Getenv("TRIVY_NEW_JSON_SCHEMA") == "" {
|
||||
// After migrating to the new JSON schema, TRIVY_NEW_JSON_SCHEMA will be removed.
|
||||
log.Logger.Warnf("DEPRECATED: the current JSON schema is deprecated, check %s for more information.",
|
||||
"https://github.com/aquasecurity/trivy/discussions/1050")
|
||||
v = report.Results
|
||||
}
|
||||
|
||||
output, err := json.MarshalIndent(v, "", " ")
|
||||
output, err := json.MarshalIndent(report, "", " ")
|
||||
if err != nil {
|
||||
return xerrors.Errorf("failed to marshal json: %w", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user