-
-
Notifications
You must be signed in to change notification settings - Fork 296
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
Implement Cobra CLI tooling, Viper config tooling #336
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
leopku
pushed a commit
to leopku/gotosocial
that referenced
this pull request
Dec 8, 2021
…ss#336) * start pulling out + replacing urfave and config * replace many many instances of config * move more stuff => viper * properly remove urfave * move some flags to root command * add testrig commands to root * alias config file keys * start adding cli parsing tests * reorder viper init * remove config path alias * fmt * change config file keys to non-nested * we're more or less in business now * tidy up the common func * go fmt * get tests passing again * add note about the cliparsing tests * reorganize * update docs with changes * structure cmd dir better * rename + move some files around * fix dangling comma
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request replaces the urfave cli tooling we were using, with Cobra, which provides a bit more flexible CLI functionality, and fixes some of the messy CLI code we had in the
cmd
folder where we had to work around some bugs and issues with urfave.It also removes our current config implementation (passing a pointer to a static config struct around), and replaces it with a centralized configuration store provided by Viper.
This means that configuration can now be read from anywhere by calling the Viper singleton, without the need for an instantiated config struct. This is similar to the changes we made a while ago to our Logrus logging (use a global logger instead of passing the same logger pointer around everywhere).
This should pave the way to working on this issue: #270 , since Viper also allows 'watching' a config file and live reloading config, but that can be another PR.
BREAKING CHANGES !!!!
In order to implement cobra/viper properly, some of the configuration keys had to change. This has been updated in the documentation. When a release is done that includes this PR, we need a big WARNING on the PR to instruct people that they will probably have to update their config files / deployments with the new config keys.
Closes #42