mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-03 19:58:17 +00:00 
			
		
		
		
	Fix staticcheck failures in test/utils/...
				
					
				
			The `err` return value was being overwritten in an unintended way, which means the function may not return the proper error value. This diff ensures it does.
This commit is contained in:
		@@ -124,7 +124,6 @@ test/integration/serviceaccount
 | 
				
			|||||||
test/integration/serving
 | 
					test/integration/serving
 | 
				
			||||||
test/integration/ttlcontroller
 | 
					test/integration/ttlcontroller
 | 
				
			||||||
test/integration/volume
 | 
					test/integration/volume
 | 
				
			||||||
test/utils
 | 
					 | 
				
			||||||
vendor/k8s.io/apimachinery/pkg/api/meta
 | 
					vendor/k8s.io/apimachinery/pkg/api/meta
 | 
				
			||||||
vendor/k8s.io/apimachinery/pkg/api/resource
 | 
					vendor/k8s.io/apimachinery/pkg/api/resource
 | 
				
			||||||
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured
 | 
					vendor/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -137,7 +137,6 @@ func CheckForDuplicates(el auditinternal.EventList) (auditinternal.EventList, er
 | 
				
			|||||||
	// existingEvents holds a slice of audit events that have been seen
 | 
						// existingEvents holds a slice of audit events that have been seen
 | 
				
			||||||
	existingEvents := []AuditEvent{}
 | 
						existingEvents := []AuditEvent{}
 | 
				
			||||||
	duplicates := auditinternal.EventList{}
 | 
						duplicates := auditinternal.EventList{}
 | 
				
			||||||
	var err error
 | 
					 | 
				
			||||||
	for _, e := range el.Items {
 | 
						for _, e := range el.Items {
 | 
				
			||||||
		event, err := testEventFromInternal(&e)
 | 
							event, err := testEventFromInternal(&e)
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
@@ -147,12 +146,17 @@ func CheckForDuplicates(el auditinternal.EventList) (auditinternal.EventList, er
 | 
				
			|||||||
		for _, existing := range existingEvents {
 | 
							for _, existing := range existingEvents {
 | 
				
			||||||
			if reflect.DeepEqual(existing, event) {
 | 
								if reflect.DeepEqual(existing, event) {
 | 
				
			||||||
				duplicates.Items = append(duplicates.Items, e)
 | 
									duplicates.Items = append(duplicates.Items, e)
 | 
				
			||||||
				err = fmt.Errorf("failed duplicate check")
 | 
					 | 
				
			||||||
				continue
 | 
									continue
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		existingEvents = append(existingEvents, event)
 | 
							existingEvents = append(existingEvents, event)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						var err error
 | 
				
			||||||
 | 
						if len(duplicates.Items) > 0 {
 | 
				
			||||||
 | 
							err = fmt.Errorf("failed duplicate check")
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return duplicates, err
 | 
						return duplicates, err
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user