kaoto
kaoto copied to clipboard
Clean up `KameletResource` and `KameletVisualEntity` classes
Please describe the task that needs to be done
Context
As reported in #594, there's a situation that prevents the user from editing Kamelets.
This bug was caused due to a problem in the serialization of the KameletResource
, because despite the Canvas Form
editing the KameletVisualEntity
correctly, what ultimately was serialized was the original Kamelet
without changes. This is handled by #651.
This change opens up a more broad topic about Kamelets
, at this moment, the KameletVisualEntity
class knows the underlying flow (kamelet.spec.template.from
) and its metadata (kamelet.metadata
), and this shouldn't be the case.
Ideally, KameletVisualEntity
would know the flow only but the issue with this is that it will close the possibility of renaming the flow, as the setId
method is defined in the KameletVisualEntity
class. A solution for this could be to create an intermediate setId
functionality in the CamelResource
interface itself which will later on delegate the change to the underlying VisualEntities.setId()
method if necessary, this way, in case of Kamelets
and Pipes
, we have the chance to update its metadata and also the underlying flow.
In addition to that, it would be convenient to offer a mechanism to sort the properties of the underlying VisualEntities
, this way we could sort the entire Kamelet
in a kubernetes
friendly way and also keep the underlying Camel Route
sorted differently.
Proposed Changes
- [ ] ~Create an intermediate method
setId
at theCamelResource
class so we can apply the id change to the metadata properties and relay it to the underlying flow if applicable. This change will remove the need for theKameletVisualEntity
class to know about theKamelet
's metadata and bring it closer to the originalAbstractCamelVisualEntity
class.~ - [ ] ~Remove the metadata properties and other customizations of the
KameletVisualEntity
class and create atoJSON
method that returns thefrom
property so it can be better incorporated into the serializing flow.~ - [ ] Receive the entire
Kamelet
definition in theKameletVisualEntity
and adapt thetoJSON
method in theKameletResource
class to accommodate if something is needed. TheKameletVisualEntity
class needs the entire definition to be able to provide a configuration panel for its different metadata properties. - [ ] Change the current "Rename a flow" path, from the existing "Rename the flow using the flow itself" towards "asking the Resource to change the name of one of its flows" instead. Note: This might not be needed if we have the entire kamelet definition in the
KameletVisualEntity