diff --git a/pkg/master/import_known_versions_test.go b/pkg/master/import_known_versions_test.go index c2aba14015f..0d19a47b29a 100644 --- a/pkg/master/import_known_versions_test.go +++ b/pkg/master/import_known_versions_test.go @@ -93,6 +93,10 @@ func ensureNoTags(t *testing.T, gvk schema.GroupVersionKind, tp reflect.Type, pa return } + // Don't look at the same type multiple times + if containsType(parents, tp) { + return + } parents = append(parents, tp) switch tp.Kind() { @@ -145,6 +149,10 @@ func ensureTags(t *testing.T, gvk schema.GroupVersionKind, tp reflect.Type, pare return } + // Don't look at the same type multiple times + if containsType(parents, tp) { + return + } parents = append(parents, tp) switch tp.Kind() { @@ -185,3 +193,13 @@ func ensureTags(t *testing.T, gvk schema.GroupVersionKind, tp reflect.Type, pare } } } + +// containsType returns true if s contains t, false otherwise +func containsType(s []reflect.Type, t reflect.Type) bool { + for _, u := range s { + if t == u { + return true + } + } + return false +}