Overhaul Configuration
Currently, glab
uses .env
configuration format to store its configuration. Global config files are stored at the user's home directory as $HOME/.glab-cli/config/.env
whereas local config files are stored in the current working directory and added to the .gitignore
file to ignore it.
This solution seems not to be ideal enough as there will be several local config files spread across different folders or working directories. (This point stands to be corrected or argued on)
Solutions An ideal solution will be to create a single user configuration file in the user's home directory that allows multiple configurations format for all working directories. Below is a solution in git config style.
[global]
GITLAB_TOKEN=xxxxxx
GITLAB_URI=https://gitlab.com
GIT_REMOTE_URL_VAR=origin
[local "namespace/repo"]
GITLAB_URI=https://gitlab.example.com
[local "namespace/repo2"]
GITLAB_TOKEN=xxxxxx
GIT_REMOTE_URL_VAR=origin-test
glab
's configuration was done to support repos with multiple remotes, assuming the GitLab's remote nickname may not always be origin
. Taking that into consideration, the above solution looks good.
However, to make the configuration simpler, YAML
can also be considered. glab
takes inspiration from gh, a GitHub CLI tool. gh
uses YAML
for its configuration and it seems to work much better with viper.
I would like to completely redo this for v2.0.0.
Configuration in YAML would be:
gitlab.com:
token: xxxxx
gitlab.example.com:
token: xyxyyx
remote-nickname: origin
remote-nicknames:
namespace/repo: origin-test
I would like to know your suggestions on the configuration file format best suited for this. We can also consider doing it in a backward-compatible way, if possible.