Skip to content
This repository has been archived by the owner on Jan 19, 2023. It is now read-only.

Commit

Permalink
namespaces - provided namespaces should always show in namespace list (
Browse files Browse the repository at this point in the history
…#2686)

Signed-off-by: Wayne Witzel III <[email protected]>
  • Loading branch information
wwitzel3 committed Jul 27, 2021
1 parent 778e278 commit a6ad1b7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
1 change: 1 addition & 0 deletions changelogs/unreleased/2259-wwitzel3
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed issue with --namespace-list not adding namespaces list.
27 changes: 15 additions & 12 deletions internal/api/namespaces_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,18 +134,9 @@ func NamespacesGenerator(_ context.Context, config NamespaceManagerConfig) ([]st
names = []string{initialNamespace}
}

for _, namespace := range providedNamespaces {
found := false
for _, foundNamespace := range names {
if namespace == foundNamespace {
found = true
break
}
}
if !found && namespaceClient.HasNamespace(namespace) {
names = append(names, namespace)
}
}
names = append(names, providedNamespaces...)
names = uniqueStringSlice(names)

return names, nil
}

Expand All @@ -158,3 +149,15 @@ func CreateNamespacesEvent(namespaces []string) oevent.Event {
},
}
}

func uniqueStringSlice(nsSlice []string) []string {
keys := make(map[string]bool)
list := []string{}
for _, entry := range nsSlice {
if _, value := keys[entry]; !value {
keys[entry] = true
list = append(list, entry)
}
}
return list
}
1 change: 0 additions & 1 deletion pkg/dash/dash_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ func mockClusterClientReturningNamespace(controller *gomock.Controller, namespac
nsClient.EXPECT().InitialNamespace().Return(namespace)
nsClient.EXPECT().ProvidedNamespaces().Return([]string{namespace})
nsClient.EXPECT().Names().AnyTimes()
nsClient.EXPECT().HasNamespace(namespace).Return(true)

dynamicClient := clusterFake.NewMockDynamicInterface(controller)

Expand Down

0 comments on commit a6ad1b7

Please sign in to comment.