Skip to content

Commit

Permalink
docs update
Browse files Browse the repository at this point in the history
Signed-off-by: Attila Mészáros <csviri@gmail.com>
  • Loading branch information
csviri committed Mar 11, 2024
1 parent aa84517 commit 43f3002
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
15 changes: 5 additions & 10 deletions docs/documentation/dependent-resources.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,7 @@ conditionally creating an `Ingress`:

@ControllerConfiguration
public class WebPageStandaloneDependentsReconciler
implements Reconciler<WebPage>, ErrorStatusHandler<WebPage>,
EventSourceInitializer<WebPage> {
implements Reconciler<WebPage>, ErrorStatusHandler<WebPage> {

private KubernetesDependentResource<ConfigMap, WebPage> configMapDR;
private KubernetesDependentResource<Deployment, WebPage> deploymentDR;
Expand Down Expand Up @@ -307,16 +306,12 @@ public class WebPageStandaloneDependentsReconciler
There are multiple things happening here:

1. Dependent resources are explicitly created and can be access later by reference.
2. Event sources are produced by the dependent resources, but needs to be explicitly registered in
this case by implementing
the [`EventSourceInitializer`](https://github.com/java-operator-sdk/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/EventSourceInitializer.java)
interface.
3. The input html is validated, and error message is set in case it is invalid.
4. Reconciliation of dependent resources is called explicitly, but here the workflow
2. The input html is validated, and error message is set in case it is invalid.
3. Reconciliation of dependent resources is called explicitly, but here the workflow
customization is fully in the hand of the developer.
5. An `Ingress` is created but only in case `exposed` flag set to true on custom resource. Tries to
4. An `Ingress` is created but only in case `exposed` flag set to true on custom resource. Tries to
delete it if not.
6. Status is set in a different way, this is just an alternative way to show, that the actual state
5. Status is set in a different way, this is just an alternative way to show, that the actual state
can be read using the reference. This could be written in a same way as in the managed example.

See the full source code of
Expand Down
17 changes: 9 additions & 8 deletions docs/documentation/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -491,18 +491,19 @@ related [method](https://github.com/java-operator-sdk/java-operator-sdk/blob/mai
### Registering Event Sources
To register event sources, your `Reconciler` has to implement the
[`EventSourceInitializer`](https://github.com/java-operator-sdk/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/EventSourceInitializer.java)
interface and initialize a list of event sources to register. One way to see this in action is
To register event sources, your `Reconciler` has to override the `prepareEventSources` and return
list of event sources to register. One way to see this in action is
to look at the
[tomcat example](https://github.com/java-operator-sdk/java-operator-sdk/blob/main/sample-operators/tomcat-operator/src/main/java/io/javaoperatorsdk/operator/sample/TomcatReconciler.java)
(irrelevant details omitted):
```java
@ControllerConfiguration
public class TomcatReconciler implements Reconciler<Tomcat>, EventSourceInitializer<Tomcat> {
public class TomcatReconciler implements Reconciler<Tomcat> {
// omitted code
@Override
public List<EventSource> prepareEventSources(EventSourceContext<Tomcat> context) {
var configMapEventSource =
Expand All @@ -511,9 +512,9 @@ public class TomcatReconciler implements Reconciler<Tomcat>, EventSourceInitiali
.withSecondaryToPrimaryMapper(
Mappers.fromAnnotation(ANNOTATION_NAME, ANNOTATION_NAMESPACE)
.build(), context));
return EventSourceInitializer.nameEventSources(configMapEventSource);
return EventSourceUtils.nameEventSources(configMapEventSource);
}
...
}
```
Expand Down Expand Up @@ -678,7 +679,7 @@ configured appropriately so that the `followControllerNamespaceChanges` method r

@ControllerConfiguration
public class MyReconciler
implements Reconciler<TestCustomResource>, EventSourceInitializer<TestCustomResource> {
implements Reconciler<TestCustomResource> {

@Override
public Map<String, EventSource> prepareEventSources(
Expand All @@ -689,7 +690,7 @@ public class MyReconciler
.withNamespacesInheritedFromController(context)
.build(), context);

return EventSourceInitializer.nameEventSources(configMapES);
return EventSourceUtils.nameEventSources(configMapES);
}

}
Expand Down
4 changes: 4 additions & 0 deletions docs/documentation/v5-0-migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ permalink: /docs/v5-0-migration
1. [Result of managed dependent resources](https://github.com/operator-framework/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/dependent/managed/ManagedDependentResourceContext.java#L55-L57)
is not `Optional` anymore. In case you use this result, simply use the result
objects directly.
2. `EventSourceInitializer` is not a separate interface anymore. It is part of the `Reconciler` interface with a
default implementation. You can simply remove this interface from your reconciler. The
[`EventSourceUtils`](https://github.com/operator-framework/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/EventSourceUtils.java#L11-L11)
contains all the utility classes for naming that was in the interface before.
4 changes: 2 additions & 2 deletions docs/documentation/workflows.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ page sample):
@ControllerConfiguration(
labelSelector = WebPageDependentsWorkflowReconciler.DEPENDENT_RESOURCE_LABEL_SELECTOR)
public class WebPageDependentsWorkflowReconciler
implements Reconciler<WebPage>, ErrorStatusHandler<WebPage>, EventSourceInitializer<WebPage> {
implements Reconciler<WebPage>, ErrorStatusHandler<WebPage> {

public static final String DEPENDENT_RESOURCE_LABEL_SELECTOR = "!low-level";
private static final Logger log =
Expand All @@ -147,7 +147,7 @@ public class WebPageDependentsWorkflowReconciler

@Override
public Map<String, EventSource> prepareEventSources(EventSourceContext<WebPage> context) {
return EventSourceInitializer.nameEventSources(
return EventSourceUtils.nameEventSources(
configMapDR.initEventSource(context),
deploymentDR.initEventSource(context),
serviceDR.initEventSource(context),
Expand Down

0 comments on commit 43f3002

Please sign in to comment.