commit
f2f846de9e
|
@ -8,7 +8,6 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/r3labs/diff/v2"
|
||||
|
||||
"github.com/snyk/driftctl/pkg/alerter"
|
||||
"github.com/snyk/driftctl/pkg/resource"
|
||||
)
|
||||
|
@ -64,6 +63,7 @@ type serializableAnalysis struct {
|
|||
Alerts map[string][]alerter.SerializableAlert `json:"alerts"`
|
||||
ProviderName string `json:"provider_name"`
|
||||
ProviderVersion string `json:"provider_version"`
|
||||
ScanDuration uint `json:"scan_duration,omitempty"`
|
||||
}
|
||||
|
||||
type GenDriftIgnoreOptions struct {
|
||||
|
@ -107,6 +107,7 @@ func (a Analysis) MarshalJSON() ([]byte, error) {
|
|||
bla.Coverage = a.Coverage()
|
||||
bla.ProviderName = a.ProviderName
|
||||
bla.ProviderVersion = a.ProviderVersion
|
||||
bla.ScanDuration = uint(a.Duration.Seconds())
|
||||
|
||||
return json.Marshal(bla)
|
||||
}
|
||||
|
@ -167,7 +168,8 @@ func (a *Analysis) UnmarshalJSON(bytes []byte) error {
|
|||
}
|
||||
a.ProviderName = bla.ProviderName
|
||||
a.ProviderVersion = bla.ProviderVersion
|
||||
a.summary.TotalIaCSourceCount = bla.Summary.TotalIaCSourceCount
|
||||
a.SetIaCSourceCount(bla.Summary.TotalIaCSourceCount)
|
||||
a.Duration = time.Duration(bla.ScanDuration) * time.Second
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/snyk/driftctl/pkg/filter"
|
||||
"github.com/stretchr/testify/mock"
|
||||
|
@ -1269,7 +1270,9 @@ func addSchemaToRes(res *resource.Resource, repo resource.SchemaRepositoryInterf
|
|||
|
||||
func TestAnalysis_MarshalJSON(t *testing.T) {
|
||||
goldenFile := "./testdata/output.json"
|
||||
analysis := Analysis{}
|
||||
analysis := Analysis{
|
||||
Duration: 241 * time.Second,
|
||||
}
|
||||
analysis.SetIaCSourceCount(1)
|
||||
analysis.AddManaged(
|
||||
&resource.Resource{
|
||||
|
|
|
@ -70,5 +70,6 @@
|
|||
]
|
||||
},
|
||||
"provider_name": "AWS",
|
||||
"provider_version": "2.18.5"
|
||||
"provider_version": "2.18.5",
|
||||
"scan_duration": 241
|
||||
}
|
|
@ -4,6 +4,7 @@ import (
|
|||
"fmt"
|
||||
"reflect"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/r3labs/diff/v2"
|
||||
|
@ -23,6 +24,7 @@ func fakeAnalysis(opts analyser.AnalyzerOptions) *analyser.Analysis {
|
|||
}
|
||||
a := analyser.NewAnalysis(opts)
|
||||
a.SetIaCSourceCount(3)
|
||||
a.Duration = 12 * time.Second
|
||||
a.AddUnmanaged(
|
||||
&resource.Resource{
|
||||
Id: "unmanaged-id-1",
|
||||
|
|
|
@ -107,5 +107,6 @@
|
|||
"coverage": 33,
|
||||
"alerts": null,
|
||||
"provider_name": "AWS",
|
||||
"provider_version": "3.19.0"
|
||||
"provider_version": "3.19.0",
|
||||
"scan_duration": 12
|
||||
}
|
Loading…
Reference in New Issue