Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pkg/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ func DoSearch(stores []storetypes.KubeconfigStore, config *types.Config, stateDi

resultChannel := make(chan DiscoveredContext)
wgResultChannel := sync.WaitGroup{}
wgResultChannel.Add(len(stores))
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that we don't have the wait counter set up here any more, can we still call waitGroup.done() here when we read from the index? Looks to me like we wouldn't have a corresponding Add() any more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure to understand where to .done() ^^


for _, kubeconfigStore := range stores {
logger := kubeconfigStore.GetLogger()
Expand Down Expand Up @@ -138,7 +137,11 @@ func DoSearch(stores []storetypes.KubeconfigStore, config *types.Config, stateDi
store.StartSearch(channel)
}(kubeconfigStore, c)

wgResultChannel.Add(1)
go func(store storetypes.KubeconfigStore, storeSearchChannel chan storetypes.SearchResult, index index.SearchIndex) {

defer wgResultChannel.Done()

// remember the context to kubeconfig path mapping for this store
// to write it to the index. Do not use the global "ContextToPathMapping"
// as this contains contexts names from all stores combined
Expand Down Expand Up @@ -204,9 +207,6 @@ func DoSearch(stores []storetypes.KubeconfigStore, config *types.Config, stateDi
if len(localContextToPathMapping) > 0 {
writeIndex(store, &index, localContextToPathMapping, localContextToTagsMapping)
}

// reading from this store is finished, decrease wait counter
wgResultChannel.Done()
}(kubeconfigStore, c, *searchIndex)
}

Expand Down