Skip to content

Commit 0b78047

Browse files
committed
wip
Signed-off-by: Attila Mészáros <csviri@gmail.com>
1 parent 50e38c3 commit 0b78047

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/BaseConfigurationService.java

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import io.fabric8.kubernetes.client.informers.cache.ItemStore;
1717
import io.javaoperatorsdk.operator.ReconcilerUtils;
1818
import io.javaoperatorsdk.operator.api.config.Utils.Configurator;
19-
import io.javaoperatorsdk.operator.api.config.dependent.DependentResourceConfigurationResolver;
2019
import io.javaoperatorsdk.operator.api.config.dependent.DependentResourceSpec;
2120
import io.javaoperatorsdk.operator.api.config.workflow.WorkflowSpec;
2221
import io.javaoperatorsdk.operator.api.reconciler.Constants;
@@ -224,6 +223,45 @@ private <P extends HasMetadata> ResolvedControllerConfiguration<P> controllerCon
224223
this, informerListLimit);
225224
}
226225

226+
@SuppressWarnings({"unchecked", "rawtypes"})
227+
private static List<DependentResourceSpec> dependentResources(
228+
Workflow annotation,
229+
ControllerConfiguration<?> parent) {
230+
final var dependents = annotation.dependents();
231+
232+
233+
if (dependents == null || dependents.length == 0) {
234+
return Collections.emptyList();
235+
}
236+
237+
final var specsMap = new LinkedHashMap<String, DependentResourceSpec>(dependents.length);
238+
for (Dependent dependent : dependents) {
239+
final Class<? extends DependentResource> dependentType = dependent.type();
240+
241+
final var dependentName = getName(dependent.name(), dependentType);
242+
var spec = specsMap.get(dependentName);
243+
if (spec != null) {
244+
throw new IllegalArgumentException(
245+
"A DependentResource named '" + dependentName + "' already exists: " + spec);
246+
}
247+
248+
final var name = parent.getName();
249+
250+
var eventSourceName = dependent.useEventSourceWithName();
251+
eventSourceName = Constants.NO_VALUE_SET.equals(eventSourceName) ? null : eventSourceName;
252+
final var context = Utils.contextFor(name, dependentType, null);
253+
spec = new DependentResourceSpec(dependentType, dependentName,
254+
Set.of(dependent.dependsOn()),
255+
Utils.instantiate(dependent.readyPostcondition(), Condition.class, context),
256+
Utils.instantiate(dependent.reconcilePrecondition(), Condition.class, context),
257+
Utils.instantiate(dependent.deletePostcondition(), Condition.class, context),
258+
Utils.instantiate(dependent.activationCondition(), Condition.class, context),
259+
eventSourceName);
260+
specsMap.put(dependentName, spec);
261+
}
262+
return specsMap.values().stream().toList();
263+
}
264+
227265
protected boolean createIfNeeded() {
228266
return true;
229267
}

0 commit comments

Comments
 (0)