-
Notifications
You must be signed in to change notification settings - Fork 75
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: new configuration system, config subcommand #736
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #736 +/- ##
==========================================
- Coverage 60.14% 59.32% -0.83%
==========================================
Files 191 203 +12
Lines 6808 7484 +676
==========================================
+ Hits 4095 4440 +345
- Misses 2099 2402 +303
- Partials 614 642 +28 ☔ View full report in Codecov by Sentry. |
f895daf
to
8b2856d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, I like how it is structured.
I think a few refactoring passes are needed before this can be merged.
I also noticed that the viper library already ships our previous toml library, so might be shipping both. Are we ok with the binary size?
I'll put the toml library change into another PR and then we can compare binary sizes. I don't think it's a huge difference. Edit: See #758 |
dd2eda9
to
69096d4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Partial review (its a huge PR ;) ), will continue tomorrow :)
…ontext active error message
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Took another look.
Do you think it would be possible to add the config.OptionQuiet
options inside the config struct? This way we would only have the config struct in the state and get the value from it?
So instead of config.OptionQuiet.Get(s.Config())
we would simply have s.Config().Quiet()
?
Other than that, there is a bunch of code that can be deduplicated, extracted in smaller functions, so the higher level logic is easier to understand.
This would technically be possible, but has a lot of drawbacks:
I considered the approach you described while implementing the spec, however the current approach offers way more concise code (it only takes a call of the
Feel free to comment those parts in your review. |
I don't think it increases the duplication too much, it is moving some code around. Instead of having "complex" code in the business logic, we have dumb code in the config package (at least we have a dumb API, and hide the complexity).
I am not sure if this is a real problem, we could have dedicated config struct for testing that embed the normal config struct.
I prefer to clutter the config interface instead of the business code. Ensuring a proper separation of concern with simple APIs, will make the project easier to work with.
Will do. |
That said, I don't have a strong opinion. I just wanted to discuss the topic, to see if we can have an even better API. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is getting better and better, I like it!
I added the few comment in places I though we could deduplicate/move some code.
In the current implementation you need:
If options were implemented on the config interface, you would need:
This is tedious and would definitely need to be documented somewhere. Also it could be easy to forget some steps, especially for someone in the future who didn't read this PR.
I'm not sure if I understand you correctly here, but that's not how structs work in Go. You'd need an interface to abstract everything away (which would mean even more code duplication)
Fair point, but I don't think
That's completely valid. As I said, I first followed the approach you proposed too when implementing the spec, but it really didn't make that much sense. It might have a prettier outer-facing API, but remember that we have to maintain the actual implementation as well. |
can configure a per-directory context by setting `HCLOUD_CONTEXT=my-context` via `.envrc`. | ||
## Configuring hcloud | ||
|
||
The hcloud CLI tool allows configuration using following methods: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The hcloud CLI tool allows configuration using following methods: | |
The hcloud CLI tool can be configured using following methods: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about "can be configured"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes work for me.
Alright, case close from my side then. |
Co-authored-by: Jonas L. <jooola@users.noreply.github.com>
This PR implements the new configuration system as described in #762.
Closes #762
In preparation for #434