-
Notifications
You must be signed in to change notification settings - Fork 51
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
Allow DI for condition and discriminator classes #720
Comments
It would be also useful to support constructor based injection 🙂 |
Could you elaborate, please? |
Yes, of course. So, if we have a configuration like below:
Then, constructor based injection won't work (tested with quarkus-operator-sdk 6.3.0):
It seems to be failing even in build phase 🤔 And for the second part of the question - it is not possible to inject when using So from my point of view, it would be nice if any property of Any thoughts? |
JOSDK should allow conditions and discriminators to be CDI beans, i.e. if the referenced class, let's say |
Just a small remark, discriminators are probably going away in v5: |
@Javatar81 would the approach described in operator-framework/java-operator-sdk#2252 work in your use case? |
I am currently migrating all my discriminator to the |
This makes me think that we could remove discriminators from the list for CDI managed beans. However, I think we still need it for the classes referenced in the following attributes of
|
Note that the dependent resources (the |
One issue with making the conditions beans, is that we wouldn't be able to completely resolve the workflows at build time as is currently the case, if I'm not mistaken… This is something I need to think about more. |
Another issue is that all these classes have the same type so I'm not sure how resolution would work since we would probably need to add a qualifier to distinguish them, which starts to make things rather complicated. Maybe I'm not just seeing well how things would work in that scenario… |
@Javatar81 @AleksanderBrzozowski is this still something you are interested in? If yes, could you provide more details as to what you'd like to be able to do more specifically, in particular with respect to how CDI would handle the fact that conditions all share the same base type? |
So, what we do is we have a class which extends from For the condition to pass, the properties are not needed. |
There are several attributes that refer to a singleton object represented by its Class, e.g. conditions and discriminators. Examples are:
There is no way to inject additional dependencies into these classes since they are always instantiated via their default constructor. It would be useful to support attribute and constructor injection via CDI.
One use case is to inject the
OpenShiftClient
into a reconcile precondition class to implement checks agains the OCP API.The text was updated successfully, but these errors were encountered: