|
| 1 | +--- |
| 2 | +title: Migrating from v1 to v2 |
| 3 | +description: Migrating from v1 to v2 |
| 4 | +layout: docs |
| 5 | +permalink: /docs/v2-migration |
| 6 | +--- |
| 7 | + |
| 8 | +# Migrating from v1 to v2 |
| 9 | + |
| 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 |
| 15 | +see [this issue](https://github.com/java-operator-sdk/java-operator-sdk/issues/655) |
| 16 | + |
| 17 | +## User Facing API Changes |
| 18 | + |
| 19 | +The following items are renamed and slightly changed: |
| 20 | + |
| 21 | +- [`ResourceController`](https://github.com/java-operator-sdk/java-operator-sdk/blob/v1/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/ResourceController.java) |
| 22 | + interface is renamed |
| 23 | + to [`Reconciler`](https://github.com/java-operator-sdk/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/Reconciler.java) |
| 24 | + . In addition, methods: |
| 25 | + - `createOrUpdate` renamed to `reconcile` |
| 26 | + - `delete` renamed to `cleanup` |
| 27 | +- Events are removed from |
| 28 | + 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. |
| 31 | +- The `init` method is extracted from `ResourceController` / `Reconciler` to a separate interface |
| 32 | + 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 |
| 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) |
| 39 | + , and it's interface refined. |
| 40 | +- [`@Controller`](https://github.com/java-operator-sdk/java-operator-sdk/blob/v1/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/Controller.java) |
| 41 | + annotation renamed |
| 42 | + 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) |
| 43 | + |
| 44 | +### Event Sources |
| 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 |
| 48 | + 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. |
| 51 | +- [`EventSource`](https://github.com/java-operator-sdk/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/source/EventSource.java) |
| 52 | + is refactored, but the changes are trivial. |
| 53 | + |
0 commit comments