-
Notifications
You must be signed in to change notification settings - Fork 220
fix: clean up controller default name generation #282
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
8bae9ab
fix: clean up controller default name generation
metacosm 364066a
fix: tests
metacosm d12bb06
feat: factor out ControllerConfiguration registration
metacosm cc819e1
feat: revert use of canonical class name as default controller name
metacosm 1a851ef
refactor: move naming generation methods back to ControllerUtils
metacosm dc4b96f
refactor: remove getName method from ResourceController
metacosm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
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.
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.
Wonder why these methods are needed to be here. Let's keep the interfaces as clean and relevant as possible!
I still believe the getName also should be pulled out from this interface, I think it's been missed in the main PR wrt quarkus extension.
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.
We don't need to put these methods there, it just that it made sense to me to move them here since they pertain to
ResourceControllers
instead of adding them to a util class that's less discoverable.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.
@psycho-ir why do you think the
getName
method should be pulled? It's needed to be able to configure controllers individually.Uh oh!
There was an error while loading. Please reload this page.
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.
It let the user set the controller name in 2 different ways, @Controller.name & overriding the
getName
method and that's what we should strive to avoid.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.
Ah yes, didn't think of that but I assume that someone would need to know what they're doing if they override the default
getName
method… since we provide a default implementation. And if they provide their own implementation, then I guess that's the one that would be used and the annotation would be ignored anyway. I don't think that's something that would be an issue in practice.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.
Well, API design is mainly about the things we let users do and the reason behind them.
The getName method has been implemented for internal use and is effectively final (no reason to be overridden by the client).
Having that in the interface as the method will lead to other questions like why
finalizerName
,crdName
,generationAwareEventProcessing
and so on don't have getter method in interface accordingly if there is a getter method with default implementation why @controller annotation is getting thename
field too? and several similar questions.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 name is not internal: to be able to configure a controller, you need to be able to identify it. That's the name's purpose. While there are no obvious reasons that I can think of to override the default naming scheme, some people might still want to provide their own way to name a controller independently of what we provide (because for example, they're not using annotations and don't want to incur that impact at runtime). As such, it makes sense (at least to me) that it lives on the
ResourceController
interface.The other methods, on the other hand, are part of the controller's configuration, which, again, you can't retrieve without first knowing the name of the controller. These values are not part of what is essential to the controller.
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.
In comment, I was talking about the getName and not name, ofc name is not an internal thing, thus the user can set it via @Controller.name.
getName for sure can be added later on (it's backward compatible change) to the interface if it's been decided to get controller essential configuration from anywhere other than the controller annotation, AFAIK it's not currently the case and annotation + its crdName property is required.
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.
Fixed.