INNER CODE UNIT · Go
shouldReadFromIndex
danielfoehrKn/kubeswitch · pkg/search.go:221
func shouldReadFromIndex(searchIndex *index.SearchIndex, kubeconfigStore storetypes.KubeconfigStore, config *types.Config) (bool, error) {
// never write an index for the store from env variables and --kubeconfig-path command line falg
if kubeconfigStore.GetID() == fmt.Sprintf("%s.%s", types.StoreKindFilesystem, "env-and-flag") {
return false, nil
}
if searchIndex.HasContent() && searchIndex.HasKind(kubeconfigStore.GetKind()) {
// found an index for the correct Store kind
// check if should use existing index or not
shouldReadFromIndex, err := searchIndex.ShouldBeUsed(config, kubeconfigStore.GetStoreConfig().RefreshIndexAfter)
if err != nil {
return false, err
}
return shouldReadFromIndex, nil
}
return false, nil
}