-
Notifications
You must be signed in to change notification settings - Fork 219
feat: configure resource class and name for controller #1781
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
Conversation
} | ||
|
||
public ControllerConfigurationOverrider<R> withResourceClass(Class<R> resourceClass) { | ||
this.resourceClass = resourceClass; |
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 feels weird to override a given controller configuration with a different resource type so I'm not sure about this one…
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 think it was added there if there is some hierarchy or something in reconciler, and cannot be detected as we do now. in that terms it makes sense to me.
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 problem is that it opens the door for improper usage so I'd rather see this support moved somewhere outside of the overrider. The goal of the overrider is to change the configuration provided by the annotations at runtime, not to create a new configuration from scratch. As such, since the resource type is mandated by the parameter type of the Reconciler
implementation, it shouldn't be possible to override it at runtime so the more I think about it, the more against this change I am.
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.
Hmm, that is right. The problem is it's not possible to specify it by @ControllerConfiguration
. Shall we put it rather there?
Would be a better solution.
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.
That would be a huge change and a redundant information with the Reconciler
implementation.
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.
Again, I fail to see how things would work if you were to override the resource type and end up with something that doesn't match your Reconciler implementation… If people want to have a hierarchy, the resource type parameter should be propagated along it.
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.
kk, let's remove this option
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.
revisited this again, and we would break this functionality provided by the users:
https://github.com/java-operator-sdk/operator-framework-spring-boot-starter/blob/182b1111990f99d6516d2965f54dddca8c1cf6de/starter/src/main/java/io/javaoperatorsdk/operator/springboot/starter/OperatorAutoConfiguration.java#L103-L107
if we remove this. What is bad.
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.
Basically there is no other way to configure this through our public API, just maybe hacking it with some custom config service, what is problematic. So I think we should allow this to be configured and document it, that this is just for framework support.
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.
Basically there is no other way to configure this through our public API, just maybe hacking it with some custom config service, what is problematic. So I think we should allow this to be configured and document it, that this is just for framework support.
That is not true: the current way to do it is to provide your own ControllerConfiguration
implementation (or extend the existing ConfigurationService
implementations) but I do agree that we could make things easier.
e7affe1
to
fa57cd7
Compare
Note that this is technically a breaking API change. |
return (Class<P>) Utils.getFirstTypeArgumentFromSuperClassOrInterface(getClass(), | ||
ControllerConfiguration.class); | ||
} | ||
Class<P> getResourceClass(); |
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 should keep a default implementation to avoid breaking the 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.
Well, yes, althoug not really the API, it's the implementation. But we should remove it in the future, to make it more explicit that this is not used
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 is ok to do ti for next? (I mean a separate PR, wdyt?)
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.
No, this method should stay as it's needed by some implementations, Quarkus in particular. And it is breaking the API because implementations that were relying on the provided default implementation won't compile anymore with this change.
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.
reverted and commented it for now, but I guess we can adjust also quarkus in the future if it will be removed.
For now fine to have it there IMO.
This PR should be ready now, also the adjusted spring boot part.
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 don't think that this will change in Quarkus because the resource class is resolved at build time and is therefore fixed then, not resolved at runtime, which is why we need this method to stay as-is.
Kudos, SonarCloud Quality Gate passed! |
this is mostly needed so we are able to nicely upgrade the spring boot starter to 4.2.x of JOSDK