You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
title: Migrating from v1 to v2 description: Migrating from v1 to v2 layout: docs permalink:
3
+
/docs/v2-migration
6
4
---
7
5
8
6
# Migrating from v1 to v2
9
7
10
-
Version 2 of the framework introduces improvements, features and breaking changes for the APIs both internal and user
11
-
facing ones. The migration should be however trivial in most of the cases. For detailed overview of all major issues
12
-
until the release of
13
-
v`2.0.0`[see milestone on GitHub](https://github.com/java-operator-sdk/java-operator-sdk/milestone/1). For a summary
14
-
and reasoning behind some naming changes
8
+
Version 2 of the framework introduces improvements, features and breaking changes for the APIs both
9
+
internal and user facing ones. The migration should be however trivial in most of the cases. For
10
+
detailed overview of all major issues until the release of
11
+
v`2.0.0`[see milestone on GitHub](https://github.com/java-operator-sdk/java-operator-sdk/milestone/1)
12
+
. For a summary and reasoning behind some naming changes
15
13
see [this issue](https://github.com/java-operator-sdk/java-operator-sdk/issues/655)
16
14
17
15
## User Facing API Changes
@@ -26,28 +24,35 @@ The following items are renamed and slightly changed:
26
24
-`deleteResource` renamed to `cleanup`
27
25
- Events are removed from
28
26
the [`Context`](https://github.com/java-operator-sdk/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/Context.java)
29
-
of `Reconciler` methods . The rationale behind this, is that there is a consensus now on the pattern that the events
30
-
should not be used to implement a reconciliation logic.
27
+
of `Reconciler` methods . The rationale behind this, is that there is a consensus now on the
28
+
pattern that the events should not be used to implement a reconciliation logic.
31
29
- The `init` method is extracted from `ResourceController` / `Reconciler` to a separate interface
32
30
called [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)
33
-
that `Reconcile` should implement in order to register event sources. See
31
+
that `Reconciler` should implement in order to register event sources. The method has been renamed
32
+
to `prepareEventSources` and should now return a list of `EventSource` implementations that
33
+
the `Controller` will automatically register. See
34
34
also [sample](https://github.com/java-operator-sdk/java-operator-sdk/blob/main/sample-operators/tomcat-operator/src/main/java/io/javaoperatorsdk/operator/sample/WebappReconciler.java)
35
-
for usage. Here also
36
-
the [`EventSourceManager`](https://github.com/java-operator-sdk/java-operator-sdk/blob/v1/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/EventSourceManager.java)
37
-
is renamed
38
-
to [`EventSourceRegistry`](https://github.com/java-operator-sdk/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/source/EventSourceRegistry.java)
to [`@ControllerConfiguration`](https://github.com/java-operator-sdk/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/ControllerConfiguration.java)
41
+
- The metrics use `reconcile`, `cleanup` and `resource` labels instead of `createOrUpdate`, `delete`
42
+
and `cr`, respectively to match the new logic.
43
43
44
44
### Event Sources
45
45
46
-
- Addressing resources within event sources (and in the framework internally) is now changed from `.metadata.uid` to a
47
-
pair of `.metadata.name` and optional `.metadata.namespace` of resource. Represented
46
+
- Addressing resources within event sources (and in the framework internally) is now changed
47
+
from `.metadata.uid` to a pair of `.metadata.name` and optional `.metadata.namespace` of resource.
48
+
Represented
48
49
by [`ResourceID.`](https://github.com/java-operator-sdk/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/ResourceID.java)
49
-
- The [`Event`](https://github.com/java-operator-sdk/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/Event.java)
50
-
API is simplified. Now if an event source produces an event it needs to just produce an instance of this class.
50
+
-
51
+
52
+
The [`Event`](https://github.com/java-operator-sdk/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/Event.java)
53
+
API is simplified. Now if an event source produces an event it needs to just produce an instance of
Copy file name to clipboardExpand all lines: operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/ReconciliationDispatcher.java
0 commit comments