-
Notifications
You must be signed in to change notification settings - Fork 339
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
chore(*) improve resource manager initialization readability #2316
Conversation
Signed-off-by: James Peach <james.peach@konghq.com>
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 makes sense and for sure improves readability, so I'm not against merging this one
@@ -28,6 +32,9 @@ type customizableResourceManager struct { | |||
} | |||
|
|||
func (m *customizableResourceManager) Customize(resourceType model.ResourceType, manager ResourceManager) { | |||
if _, ok := m.customManagers[resourceType]; ok { | |||
panic(fmt.Sprintf("resource type %q is already customized", resourceType)) |
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.
I'd better panicked with error
rather than string
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.
There needs to be a possibility to override existing resource managers. So
- Remove the check
- Add CustomizeOpts and Override()
- Add different method called
Override(resourceType model.ResourceType, manager ResourceManager)
I'm fine with whatever is picked.
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.
I did (1)
Codecov Report
@@ Coverage Diff @@
## master #2316 +/- ##
==========================================
+ Coverage 50.78% 51.14% +0.36%
==========================================
Files 870 874 +4
Lines 40541 40589 +48
==========================================
+ Hits 20587 20759 +172
+ Misses 17959 17806 -153
- Partials 1995 2024 +29
Continue to review full report at Codecov.
|
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.
My bad, I introduced Customize method, I should have refactored the rest.
👍
@@ -28,6 +32,9 @@ type customizableResourceManager struct { | |||
} | |||
|
|||
func (m *customizableResourceManager) Customize(resourceType model.ResourceType, manager ResourceManager) { | |||
if _, ok := m.customManagers[resourceType]; ok { | |||
panic(fmt.Sprintf("resource type %q is already customized", resourceType)) |
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.
There needs to be a possibility to override existing resource managers. So
- Remove the check
- Add CustomizeOpts and Override()
- Add different method called
Override(resourceType model.ResourceType, manager ResourceManager)
I'm fine with whatever is picked.
Signed-off-by: James Peach <james.peach@konghq.com>
Signed-off-by: James Peach <james.peach@konghq.com> (cherry picked from commit 544cd03)
Summary
This refactoring is a bit gratuitous, so I'm not that concerned if we don't want to merge it :-)
I was reading the resource manager setup and it was confusing how the type map was still being initialized after already being "consumed" by customizable resource manager.
Full changelog
N/A
Issues resolved
N/A
Documentation
N/A
Testing