Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(kamelets): Edit Kamelets' nodes properties #651

Merged
merged 1 commit into from
Jan 17, 2024

Conversation

lordrip
Copy link
Member

@lordrip lordrip commented Jan 17, 2024

Context

Currently, Kamelets' nodes can't be edited using the Canvas Form, causing the changes made by the user, are not serialized into the source code.

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.

Changes

The fix is to ensure that we're serializing the
KameletVisualEntity.from as part of the resulting KameletResource.toJSON() method.

Notes

This change opens up a more broad topic about Kamelets, at this moment, the KameletVisualEntity class has knowledge about the underlying flow (kamelet.spec.template.from) and its metadata (kamelet.metadata), and this shouldn't be the case.

Ideally, KameletVisualEntity would have knowledge about 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. This will be discussed in: #652

fix: #594

Copy link
Contributor

@lhein lhein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me when testing locally.

Currently, Kamelets' nodes can't be edited using the Canvas Form,
causing the changes made by the user, are not serialized into the
source code.

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.

The fix is to ensure that we're serializing the
`KameletVisualEntity.from` as part of the resulting `KameletResource.toJSON()` method.

This change opens up a more broad topic about `Kamelets`, at this moment,
the `KameletVisualEntity` class knows about the underlying flow
(`kamelet.spec.template.from`) and its metadata (`kamelet.metadata`), and
this shouldn't be the case.

Ideally, `KameletVisualEntity` would have knowledge about 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
keeping the underlying `Camel Route` sorted differently.

fix: KaotoIO#594
@lordrip lordrip merged commit 1d2998c into KaotoIO:main Jan 17, 2024
10 checks passed
@lordrip lordrip deleted the fix/edit-kamelets branch January 17, 2024 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Source in Kamelet flow can't be edited
3 participants