-
Notifications
You must be signed in to change notification settings - Fork 95
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
feat: [V2] Rewrite config code without Viper #654
Merged
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
kentquirk
added
type: enhancement
New feature or request
wip
Work In Progress
breaking-change
Prefer 'version: bump major', but use this for breaking changes that don't bump major.
labels
Apr 2, 2023
kentquirk
changed the title
feat: [V2] WIP: configuration support code
feat: [V2] Rewrite config code without Viper
Apr 10, 2023
Tests broke; will fix. |
TylerHelmuth
approved these changes
Apr 13, 2023
TylerHelmuth
approved these changes
May 8, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
breaking-change
Prefer 'version: bump major', but use this for breaking changes that don't bump major.
type: enhancement
New feature or request
wip
Work In Progress
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 is bigger than I wanted it to be, but there were a lot of tests that needed to be updated. I did rework a number of tests to simplify the creation of sample configurations, and eliminating Viper required the creation of a couple of new functions.
I feel like this has significantly simplified the config code and made it easier to understand and maintain. Please read the comments below before reviewing the code.
Elements of this project:
Out of scope for this PR:
How to tell if we're done?
Which problem is this PR solving?
Viper is a strongly opinionated configuration tool. That can make it easy to start building something, but because in this case "opinionated" means "there's one way to do it and no easy way to change that" it can (and has, in my experience) become more and more of a maintenance problem as a codebase ages.
Refinery needs a significant rework to its configuration model:
Some of these things are possible with viper, but not all of them, and in practice Viper makes balancing these things difficult.
Short description of the changes
This PR introduces some new tools to enable us to remove Viper:
default
struct tags and applies them when called.CmdEnv
) for these things.cmdenv
struct tag in the configuration that identifies them.ConfigReloadInterval
that controls the timing of reloads; if the hash of the contents is the same, no reload occurs. This is a timed reload rather than one that depends on operating system notifications. A future PR will allow a cluster of refineries to share knowledge of a configuration change.The result is that entries in configuration structs can have up to 3 primary tags:
default
sets default valuescmdenv
when they need to be configurable on the command line and in the environmentvalidate
expresses validation rules