Skip to content

Commit

Permalink
chore: Rename ConfigAuditResult to ConfigAuditReportData (#624)
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Pacak <[email protected]>
  • Loading branch information
danielpacak authored Jun 16, 2021
1 parent 8a86fe4 commit 4dace78
Show file tree
Hide file tree
Showing 10 changed files with 111 additions and 224 deletions.
2 changes: 1 addition & 1 deletion itest/matcher/matcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func TestConfigAuditReportMatcher(t *testing.T) {
},
},
},
Report: v1alpha1.ConfigAuditResult{
Report: v1alpha1.ConfigAuditReportData{
Scanner: v1alpha1.Scanner{
Name: "Polaris",
Vendor: "Fairwinds Ops",
Expand Down
7 changes: 3 additions & 4 deletions pkg/apis/aquasecurity/v1alpha1/config_audit_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ type ConfigAuditReport struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Report ConfigAuditResult `json:"report"`
Report ConfigAuditReportData `json:"report"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
Expand All @@ -52,7 +52,7 @@ type ClusterConfigAuditReport struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Report ConfigAuditResult `json:"report"`
Report ConfigAuditReportData `json:"report"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
Expand All @@ -65,8 +65,7 @@ type ClusterConfigAuditReportList struct {
Items []ClusterConfigAuditReport `json:"items"`
}

// TODO Rename to ConfigAuditReportData
type ConfigAuditResult struct {
type ConfigAuditReportData struct {
UpdateTimestamp metav1.Time `json:"updateTimestamp"`
Scanner Scanner `json:"scanner"`
Summary ConfigAuditSummary `json:"summary"`
Expand Down
74 changes: 37 additions & 37 deletions pkg/apis/aquasecurity/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions pkg/configauditreport/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ type ReportBuilder struct {
controller metav1.Object
podSpecHash string
pluginConfigHash string
result v1alpha1.ConfigAuditResult
data v1alpha1.ConfigAuditReportData
}

func NewReportBuilder(scheme *runtime.Scheme) *ReportBuilder {
Expand All @@ -157,8 +157,8 @@ func (b *ReportBuilder) PluginConfigHash(hash string) *ReportBuilder {
return b
}

func (b *ReportBuilder) Data(result v1alpha1.ConfigAuditResult) *ReportBuilder {
b.result = result
func (b *ReportBuilder) Data(data v1alpha1.ConfigAuditReportData) *ReportBuilder {
b.data = data
return b
}

Expand Down Expand Up @@ -202,7 +202,7 @@ func (b *ReportBuilder) Get() (v1alpha1.ConfigAuditReport, error) {
Namespace: b.controller.GetNamespace(),
Labels: labels,
},
Report: b.result,
Report: b.data,
}
err = controllerutil.SetControllerReference(b.controller, &report, b.scheme)
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions pkg/configauditreport/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func TestReportBuilder(t *testing.T) {
}).
PodSpecHash("xyz").
PluginConfigHash("nop").
Data(v1alpha1.ConfigAuditResult{}).
Data(v1alpha1.ConfigAuditReportData{}).
Get()

g.Expect(err).ToNot(HaveOccurred())
Expand All @@ -56,7 +56,7 @@ func TestReportBuilder(t *testing.T) {
starboard.LabelPluginConfigHash: "nop",
},
},
Report: v1alpha1.ConfigAuditResult{},
Report: v1alpha1.ConfigAuditReportData{},
}))
}

Expand All @@ -72,8 +72,8 @@ func (p *testPlugin) GetScanJobSpec(_ starboard.PluginContext, obj client.Object
return corev1.PodSpec{}, nil, nil
}

func (p *testPlugin) ParseConfigAuditReportData(_ starboard.PluginContext, logsReader io.ReadCloser) (v1alpha1.ConfigAuditResult, error) {
return v1alpha1.ConfigAuditResult{}, nil
func (p *testPlugin) ParseConfigAuditReportData(_ starboard.PluginContext, logsReader io.ReadCloser) (v1alpha1.ConfigAuditReportData, error) {
return v1alpha1.ConfigAuditReportData{}, nil
}

func (p *testPlugin) GetContainerName() string {
Expand Down
16 changes: 8 additions & 8 deletions pkg/configauditreport/io_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func TestReadWriter(t *testing.T) {
"starboard.resource.namespace": "qa",
},
},
Report: v1alpha1.ConfigAuditResult{
Report: v1alpha1.ConfigAuditReportData{
Summary: v1alpha1.ConfigAuditSummary{
WarningCount: 8,
DangerCount: 3,
Expand Down Expand Up @@ -60,7 +60,7 @@ func TestReadWriter(t *testing.T) {
},
ResourceVersion: "1",
},
Report: v1alpha1.ConfigAuditResult{
Report: v1alpha1.ConfigAuditReportData{
Summary: v1alpha1.ConfigAuditSummary{
WarningCount: 8,
DangerCount: 3,
Expand All @@ -82,7 +82,7 @@ func TestReadWriter(t *testing.T) {
"pod-spec-hash": "h1",
},
},
Report: v1alpha1.ConfigAuditResult{
Report: v1alpha1.ConfigAuditReportData{
Summary: v1alpha1.ConfigAuditSummary{
WarningCount: 8,
DangerCount: 3,
Expand All @@ -101,7 +101,7 @@ func TestReadWriter(t *testing.T) {
"pod-spec-hash": "h2",
},
},
Report: v1alpha1.ConfigAuditResult{
Report: v1alpha1.ConfigAuditReportData{
Summary: v1alpha1.ConfigAuditSummary{
WarningCount: 9,
DangerCount: 2,
Expand Down Expand Up @@ -130,7 +130,7 @@ func TestReadWriter(t *testing.T) {
},
ResourceVersion: "1",
},
Report: v1alpha1.ConfigAuditResult{
Report: v1alpha1.ConfigAuditReportData{
Summary: v1alpha1.ConfigAuditSummary{
WarningCount: 9,
DangerCount: 2,
Expand All @@ -151,7 +151,7 @@ func TestReadWriter(t *testing.T) {
starboard.LabelResourceNamespace: "my-namespace",
},
},
Report: v1alpha1.ConfigAuditResult{},
Report: v1alpha1.ConfigAuditReportData{},
}, &v1alpha1.ConfigAuditReport{
ObjectMeta: metav1.ObjectMeta{
Namespace: "my-namespace",
Expand All @@ -162,7 +162,7 @@ func TestReadWriter(t *testing.T) {
starboard.LabelResourceNamespace: "my-namespace",
},
},
Report: v1alpha1.ConfigAuditResult{},
Report: v1alpha1.ConfigAuditReportData{},
}).Build()

readWriter := configauditreport.NewReadWriter(client)
Expand All @@ -183,7 +183,7 @@ func TestReadWriter(t *testing.T) {
starboard.LabelResourceNamespace: "my-namespace",
},
},
Report: v1alpha1.ConfigAuditResult{},
Report: v1alpha1.ConfigAuditReportData{},
}, found)
})
}
4 changes: 2 additions & 2 deletions pkg/configauditreport/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ type Plugin interface {
GetScanJobSpec(ctx starboard.PluginContext, obj client.Object) (corev1.PodSpec, []*corev1.Secret, error)

// ParseConfigAuditReportData is a callback to parse and convert logs of
// the container in a pod controlled by the scan job to v1alpha1.ConfigAuditResult.
ParseConfigAuditReportData(ctx starboard.PluginContext, logsReader io.ReadCloser) (v1alpha1.ConfigAuditResult, error)
// the container in a pod controlled by the scan job to v1alpha1.ConfigAuditReportData.
ParseConfigAuditReportData(ctx starboard.PluginContext, logsReader io.ReadCloser) (v1alpha1.ConfigAuditReportData, error)

// GetContainerName returns the name of the container in a pod created by a scan job
// to read logs from.
Expand Down
8 changes: 4 additions & 4 deletions pkg/plugin/conftest/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ func (p *plugin) GetContainerName() string {
return conftestContainerName
}

func (p *plugin) ParseConfigAuditReportData(ctx starboard.PluginContext, logsReader io.ReadCloser) (v1alpha1.ConfigAuditResult, error) {
func (p *plugin) ParseConfigAuditReportData(ctx starboard.PluginContext, logsReader io.ReadCloser) (v1alpha1.ConfigAuditReportData, error) {
var checkResults []CheckResult
err := json.NewDecoder(logsReader).Decode(&checkResults)

Expand Down Expand Up @@ -233,15 +233,15 @@ func (p *plugin) ParseConfigAuditReportData(ctx starboard.PluginContext, logsRea

imageRef, err := p.getImageRef(ctx)
if err != nil {
return v1alpha1.ConfigAuditResult{}, err
return v1alpha1.ConfigAuditReportData{}, err
}

version, err := starboard.GetVersionFromImageRef(imageRef)
if err != nil {
return v1alpha1.ConfigAuditResult{}, err
return v1alpha1.ConfigAuditReportData{}, err
}

return v1alpha1.ConfigAuditResult{
return v1alpha1.ConfigAuditReportData{
UpdateTimestamp: metav1.NewTime(p.clock.Now()),
Scanner: v1alpha1.Scanner{
Name: "Conftest",
Expand Down
14 changes: 7 additions & 7 deletions pkg/plugin/polaris/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,13 +315,13 @@ func (p *plugin) GetContainerName() string {
return polarisContainerName
}

func (p *plugin) ParseConfigAuditReportData(ctx starboard.PluginContext, logsReader io.ReadCloser) (v1alpha1.ConfigAuditResult, error) {
func (p *plugin) ParseConfigAuditReportData(ctx starboard.PluginContext, logsReader io.ReadCloser) (v1alpha1.ConfigAuditReportData, error) {
var report Report
err := json.NewDecoder(logsReader).Decode(&report)
if err != nil {
return v1alpha1.ConfigAuditResult{}, err
return v1alpha1.ConfigAuditReportData{}, err
}
return p.configAuditResultFrom(ctx, report.Results[0])
return p.configAuditReportDataFrom(ctx, report.Results[0])
}

func (p *plugin) sourceNameFrom(obj client.Object) string {
Expand All @@ -339,7 +339,7 @@ func (p *plugin) sourceNameFrom(obj client.Object) string {
)
}

func (p *plugin) configAuditResultFrom(ctx starboard.PluginContext, result Result) (v1alpha1.ConfigAuditResult, error) {
func (p *plugin) configAuditReportDataFrom(ctx starboard.PluginContext, result Result) (v1alpha1.ConfigAuditReportData, error) {
var podChecks []v1alpha1.Check
containerChecks := make(map[string][]v1alpha1.Check)

Expand Down Expand Up @@ -370,15 +370,15 @@ func (p *plugin) configAuditResultFrom(ctx starboard.PluginContext, result Resul

imageRef, err := p.getImageRef(ctx)
if err != nil {
return v1alpha1.ConfigAuditResult{}, err
return v1alpha1.ConfigAuditReportData{}, err
}

version, err := starboard.GetVersionFromImageRef(imageRef)
if err != nil {
return v1alpha1.ConfigAuditResult{}, err
return v1alpha1.ConfigAuditReportData{}, err
}

return v1alpha1.ConfigAuditResult{
return v1alpha1.ConfigAuditReportData{
Scanner: v1alpha1.Scanner{
Name: "Polaris",
Vendor: "Fairwinds Ops",
Expand Down
Loading

0 comments on commit 4dace78

Please sign in to comment.