INNER CODE UNIT · Go
Switcher
danielfoehrKn/kubeswitch · pkg/main.go:67
func Switcher(stores []storetypes.KubeconfigStore, config *types.Config, stateDir string, noIndex, showPreview bool) (*string, *string, error) {
c, err := DoSearch(stores, config, stateDir, noIndex)
if err != nil {
return nil, nil, err
}
// here we asynchronously read from the result channel until the wait group is done (call wg.Done for all stores)
go func(channel chan DiscoveredContext) {
// read from result channel until
for discoveredContext := range channel {
if discoveredContext.Error != nil {
// aggregate the errors during the search to show after the selection screen
logger.Debugf("%v", discoveredContext.Error)
searchError = multierror.Append(searchError, discoveredContext.Error)
continue
}
if discoveredContext.Store == nil {