|
5 | 5 | import io.fabric8.kubernetes.api.model.HasMetadata;
|
6 | 6 | import io.javaoperatorsdk.operator.api.reconciler.Context;
|
7 | 7 |
|
| 8 | +/** |
| 9 | + * An interface to implement and provide dependent resource support. |
| 10 | + * |
| 11 | + * @param <R> the dependent resource type |
| 12 | + * @param <P> the associated primary resource type |
| 13 | + */ |
8 | 14 | public interface DependentResource<R, P extends HasMetadata> {
|
| 15 | + |
| 16 | + /** |
| 17 | + * Reconciles the dependent resource given the desired primary state |
| 18 | + * |
| 19 | + * @param primary the primary resource for which we want to reconcile the dependent state |
| 20 | + * @param context {@link Context} providing useful contextual information |
| 21 | + * @return a {@link ReconcileResult} providing information about the reconciliation result |
| 22 | + */ |
9 | 23 | ReconcileResult<R> reconcile(P primary, Context<P> context);
|
10 | 24 |
|
| 25 | + /** |
| 26 | + * Retrieves the dependent resource associated with the specified primary one |
| 27 | + * |
| 28 | + * @param primaryResource the primary resource for which we want to retrieve the secondary |
| 29 | + * resource |
| 30 | + * @return an {@link Optional} containing the secondary resource or {@link Optional#empty()} if it |
| 31 | + * doesn't exist |
| 32 | + */ |
11 | 33 | Optional<R> getResource(P primaryResource);
|
12 | 34 |
|
| 35 | + /** |
| 36 | + * Retrieves the resource type associated with this DependentResource |
| 37 | + * |
| 38 | + * @return the resource type associated with this DependentResource |
| 39 | + */ |
13 | 40 | Class<R> resourceType();
|
14 | 41 |
|
| 42 | + /** |
| 43 | + * Computes a default name for the specified DependentResource class |
| 44 | + * |
| 45 | + * @param dependentResourceClass the DependentResource class for which we want to compute a |
| 46 | + * default name |
| 47 | + * @return the default name for the specified DependentResource class |
| 48 | + */ |
15 | 49 | @SuppressWarnings("rawtypes")
|
16 | 50 | static String defaultNameFor(Class<? extends DependentResource> dependentResourceClass) {
|
17 | 51 | return dependentResourceClass.getCanonicalName();
|
|
0 commit comments