-
Notifications
You must be signed in to change notification settings - Fork 225
fix: retrieve DependentResource based on name instead of class #1058
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
Changes from all commits
cbd1211
3ec87e8
f49eace
5b0801f
8ecf536
684289e
b7b3593
81cc3f8
3168db7
5f5ca2d
bc58211
c837a9e
c8b6dbc
dbaaa2b
3e321eb
ecac6c4
3cbab93
156a51a
6eb1890
5cefd44
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package io.javaoperatorsdk.operator; | ||
|
||
import java.util.Arrays; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
public class AggregatedOperatorException extends OperatorException { | ||
private final List<Exception> causes; | ||
|
||
public AggregatedOperatorException(String message, Exception... exceptions) { | ||
super(message); | ||
this.causes = exceptions != null ? Arrays.asList(exceptions) : Collections.emptyList(); | ||
} | ||
|
||
public AggregatedOperatorException(String message, List<Exception> exceptions) { | ||
super(message); | ||
this.causes = exceptions != null ? exceptions : Collections.emptyList(); | ||
} | ||
|
||
public List<Exception> getAggregatedExceptions() { | ||
return causes; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
package io.javaoperatorsdk.operator.api.reconciler.dependent; | ||
|
||
import static io.javaoperatorsdk.operator.api.reconciler.Constants.EMPTY_STRING; | ||
|
||
public @interface Dependent { | ||
|
||
@SuppressWarnings("rawtypes") | ||
Class<? extends DependentResource> type(); | ||
|
||
String name() default EMPTY_STRING; | ||
metacosm marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,8 +5,49 @@ | |
import io.fabric8.kubernetes.api.model.HasMetadata; | ||
import io.javaoperatorsdk.operator.api.reconciler.Context; | ||
|
||
/** | ||
* An interface to implement and provide dependent resource support. | ||
* | ||
* @param <R> the dependent resource type | ||
* @param <P> the associated primary resource type | ||
*/ | ||
public interface DependentResource<R, P extends HasMetadata> { | ||
|
||
/** | ||
* Reconciles the dependent resource given the desired primary state | ||
* | ||
* @param primary the primary resource for which we want to reconcile the dependent state | ||
* @param context {@link Context} providing useful contextual information | ||
* @return a {@link ReconcileResult} providing information about the reconciliation result | ||
*/ | ||
ReconcileResult<R> reconcile(P primary, Context<P> context); | ||
|
||
/** | ||
* Retrieves the dependent resource associated with the specified primary one | ||
* | ||
* @param primaryResource the primary resource for which we want to retrieve the secondary | ||
* resource | ||
* @return an {@link Optional} containing the secondary resource or {@link Optional#empty()} if it | ||
* doesn't exist | ||
*/ | ||
Optional<R> getResource(P primaryResource); | ||
|
||
/** | ||
* Retrieves the resource type associated with this DependentResource | ||
* | ||
* @return the resource type associated with this DependentResource | ||
*/ | ||
Class<R> resourceType(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why we need this at this level? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To make things explicit so that we don't need to rely on a default implementation that will not work in all situations. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I mean are we sure that this will be needed in all cases? I thought it is something that is required for quarkus. I guess we can then delete There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I'm conflicted on this… but the problem is that I haven't had time to spend completely focused on the extension so I'm not 100% sure about it. |
||
|
||
/** | ||
* Computes a default name for the specified DependentResource class | ||
* | ||
* @param dependentResourceClass the DependentResource class for which we want to compute a | ||
* default name | ||
* @return the default name for the specified DependentResource class | ||
*/ | ||
@SuppressWarnings("rawtypes") | ||
static String defaultNameFor(Class<? extends DependentResource> dependentResourceClass) { | ||
return dependentResourceClass.getCanonicalName(); | ||
csviri marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} |
Uh oh!
There was an error while loading. Please reload this page.