Search for config file from specific to general
Feature Request
I would like to change the order by which the config
file is loaded to start with more "specific" locations first and handle "general" locations last.
Why
I propose this change primarily because I utilize git worktree
and I would like to specify a value for the "big-bang-repo"
config key that can be dependent on my current working directory.
My typical worktree structure looks like:
~/dev/bigbang/umbrella/master
~/dev/bigbang/umbrella/development
~/dev/bigbang/umbrella/<other branches>
If my CWD is the development dir shown above, I would like to be able to have a "specific" ~/dev/bigbang/umbrella/development/.bbctl/
directory containing a config
file that contains:
"big-bang-repo": "~/dev/bigbang/umbrella/development"
I would also keep a more "general" ~/.bbctl/config
file containing
"big-bang-repo": "~/dev/bigbang/umbrella/master"
which would be the default config any time I run bbctl
anywhere besides the development worktree.
Proposed Solution
The solution to accomplish this is simply to change the ordering of the viperInstance.AddConfigPath
calls within main.go
. Additionally, I would document the search order in docs/user-guide.md
so that the behavior is clearly explained to users.
I have made these changes locally and built a test version to confirm the proposed solution actually works (i.e. bbctl config big-bang-repo
output changes based on my current CWD and the presence/absence of a ./config
or ./.bbctl/config
file). I will open an MR with these changes shortly.
Potential Issues
I am just getting started with bbctl
and there may be important reasons (unknown to me) why the config path should never change.