Merge pull request #81904 from mattjmcnaughton/mattjmcnaughton/fix-staticcheck-test-utils

Fix staticcheck failures in `test/utils/...`
This commit is contained in:
Kubernetes Prow Robot 2019-10-01 13:00:37 -07:00 committed by GitHub
commit 2f964248f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View File

@ -124,7 +124,6 @@ test/integration/serviceaccount
test/integration/serving
test/integration/ttlcontroller
test/integration/volume
test/utils
vendor/k8s.io/apimachinery/pkg/api/meta
vendor/k8s.io/apimachinery/pkg/api/resource
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured

View File

@ -137,7 +137,6 @@ func CheckForDuplicates(el auditinternal.EventList) (auditinternal.EventList, er
// existingEvents holds a slice of audit events that have been seen
existingEvents := []AuditEvent{}
duplicates := auditinternal.EventList{}
var err error
for _, e := range el.Items {
event, err := testEventFromInternal(&e)
if err != nil {
@ -147,12 +146,17 @@ func CheckForDuplicates(el auditinternal.EventList) (auditinternal.EventList, er
for _, existing := range existingEvents {
if reflect.DeepEqual(existing, event) {
duplicates.Items = append(duplicates.Items, e)
err = fmt.Errorf("failed duplicate check")
continue
}
}
existingEvents = append(existingEvents, event)
}
var err error
if len(duplicates.Items) > 0 {
err = fmt.Errorf("failed duplicate check")
}
return duplicates, err
}