Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace file searching API with a finder #1795

Closed
1 task done
sagikazarmark opened this issue Mar 25, 2024 · 0 comments · Fixed by #1849
Closed
1 task done

Replace file searching API with a finder #1795

sagikazarmark opened this issue Mar 25, 2024 · 0 comments · Fixed by #1849
Labels
kind/enhancement New feature or request

Comments

@sagikazarmark
Copy link
Collaborator

Preflight Checklist

  • I have searched the issue tracker for an issue that matches the one I want to file, without success.

Problem Description

The current API for file searching is extremely confusing, hard to explain and is full of edge cases that people rely on and then open issues/PRs with "fixes" when they break.

Examples:

The current implementation is also not very extensible (people can't workaround issues).

Proposed Solution

Deprecate the current API (SetConfigName, AddConfigPath) and replace it with a Finder interface:

type Finder interface {
    Find(fsys afero.FS) ([]string, error)
}

Finder should return a list of file paths that match a certain search criteria in the specific filesystem. (Viper uses afero as a filesystem abstraction under the hood. I don't see that going away in the short run, ie. we can't easily replace it with io/fs, so I believe it's safe to use it in the new interface)

How that search criteria is applied is up to the implementation which allows users to extend the file search implementation.

The reference implementation for Finder is locafero. To remain backwards compatible on the v1 branch we can use locafero under the hood.

Alternatives Considered

No response

Additional Information

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant