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
Rehaul Configuration #407
Comments
Personally I'd like to see an ini format but that's just me :). Let me look into this to see what I can come up with. To be clear, you have no objection to continuing to use viper. It's just that viper doesn't handle hcl very well, correct? |
Big fan of yaml personally, but toml is prefered by a lot for it's more unambiguous syntax (it's also pretty similar to ini). |
Correct, and more specifically, I want automatic environment vars to work more or less out of the box and not require all manner of shennanigans to work https://github.com/zaquestion/lab/blob/master/main.go#L54-L137 Had forgotten what |
Ditto and I think we're all in agreement that toml looks like the best approach moving forward. |
I would like to implement something that differentiates between a local and global config, just like git does. For example, if there is a local .git/lab/config, the settings in that file would override the ~/.config/lab/config settings. Doing that, however, increases complexity as there would have to be a 'lab config' command that had a --local and/or --global option. An example: .git/lab/config contains that overrides the ~/.config/lab/config [gitlab.com] The config code would always default to searching global first, and then overriding with the local values. |
Another reason we want to have global and local configs: On some projects I'm going to want the comments always displayed when doing a 'show mr', and on other projects I'm likely not going to care unless I really want it. Having a [mr show] would easily fix that type of problem. |
A few things to report. I don't think the HCL code is working at all. viper.GetString("core.token"), for example, is always empty. I've filed to see if there is any feedback. I've tried YAML (which works!), and HCL & TOML (both of which fail). |
My plan is to:
As noted in the previous comment, however, spf13/viper#967 is a problem. It could be that I just need a gentle tap on the head with a cluebat ;) and there is some subtle nature of using the other formats that I don't understand.
.git/lab This config detection order would allow users to specify a per-tree host, token, and user and easily override the global ~/.config/lab entry. While this is written focusing on the core entries (host, token, and user), it should be noted there are other config entries of tls.skip_verify and tls.ca_file. I am aware that these configs also need to be handled appropriately. |
May I also suggest to move the |
I have the first part of the plan above staged in #414. |
|
The second part is also staged in #414 |
yeah agreed, would be best to put under it's own directory |
Both first and second parts are looking good in #414! :)) Just had a couple of simple doubts, which I added in the PR. And about a lab/ folder for the config file... +1. |
lab
currently uses hcl as it's config format, and offers limited configuration. In large part minimal config options have been added to lab becausehcl
hasn't played super nicely withviper
overall (particularly the automatic env vars functionality, which we want to leverage). For 1.0 I'd like to completely redo this, with a simpler file format that plays nice with automatic env vars. The main issue that arises has to do with ambiguity among file formats on if keys are implicitly treated as arrays or not,hcl
has this issue, I thinkyaml
may as well. So I suspectjson
is going to be a top candidate here. It's also possible that viper simply has better support for this in other formats (regardless of array considerations), so it's worth looking intoyaml
andini
(git config like option).We aren't setup for this today, but in theory by using viper we should be able to read config from any number of formats. So we don't need to enforce what lab accepts, we should allow any viper formats to work (where reasonable / enabling ext suffices), but we should also settle on what the default is going to be go forward.
Lastly, out of the box this should provide improved (if not complete) support for #151 (multiple gitlab providers), this includes:
pass
) Read token from other sources (like secret/password manager) #382Related issues:
The text was updated successfully, but these errors were encountered: