Make it possible to read the configuration file from the current directory
Describe the problem you'd like to have solved
Currently, the CLI supports reading the .fga.yaml config file by default from:
- The home dir
- Or, under
fga/.fga.yamlin the user config dir
As a developer, I would like to have the .fga.yaml file on the root folder of my repo, so that I can easily find it and edit it without leaving the IDE and without the need to supply the --config param everytime I user the CLI.
Describe the ideal solution
If the CLI can also, on top of the directories mentioned above, read the .fga.yaml file from the working directory, that would be a nice improvement to the DevEx.
@OsmanMElsayed thanks for the feedback!
@rhamzeh I think this make sense, wdyt?
Thanks for the suggestion @OsmanMElsayed - yeah I also agree this would be good to have!
Awesome! Thank you folks for the fast response on this issue and bulding and maintaing this awesome product <3
I'd be happy to send a PR your way, if that's fine by you! As far as I can see it should be as simple as adding a one-liner (viper.AddConfigPath(".")) to these paths.
IMO it's more logical to add it to the top, so it takes precedence over other config files in the home directory and whatnot, but then again, that constitutes a behavioral breaking change, wdyt @rhamzeh?
My main concern here is that we might would be further away from the XDG Base Directory. And I'm not sure if there's any other unix cli tools that load from the current directory first (do you have any examples?).
That said, I do think this would be useful to folks using the FGA CLI, but just generally concerned that it is now different from the majority of the unix CLI commands.
Long term, I think we should be overhauling our config to be something similar to what k8s CLI does.
$XDG_CONFIG_HOME/
fga/
default/
fga.config.yaml
localhost/
fga.config.yaml
localhost-store1/
fga.config.yaml
remote-store1/
fga.config.yaml
allow users to switch with:
fga set-config-ctx default
or something along those lines
I'll loop in @senojj in case he has any ideas.
@OsmanMElsayed - folks correctly pointed out that git already does this as an example.
A suggestion came in that we recursively traverse directories until we reach the home dir looking for a .fga directory. I like that, but for the scope of this issue, I think your suggestion would be enough and we can tackle the traversal in a separate issue. WDYT?
Thank you for the input!
The recursive traversal makes a lot of sense 👍, and yes, let's tackle it in a separate issue (I will leave that to you guys as my go skills aren't that sharp :D).
Cool! I will create a PR soon-ish, with my suggestion.
Hi @OsmanMElsayed, I will assign this one to you. Thanks!