-
Notifications
You must be signed in to change notification settings - Fork 32
Conversation
Integration kind CRD is still not fully supported. Mixing different DSLs on the same file is not supported.
@lordrip 👀 |
@Consumes(MediaType.APPLICATION_JSON) | ||
@Produces("text/yaml") | ||
@Path("/") | ||
@CacheResult(cacheName = "api") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Caching (see above comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How would this cache behave? Is this the correct "doc" for this annotation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, exactly that one.
final @Parameter(description = "DSL to use. For example: " | ||
+ "'Kamelet Binding'.") | ||
@QueryParam("dsl") String dsl) { | ||
List<Integration> integrations = new ArrayList<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should move all this to some service and keep the resources classes clean, but better not add more changes, it is already very long.
Codecov Report
@@ Coverage Diff @@
## main #638 +/- ##
============================================
- Coverage 78.54% 77.58% -0.96%
- Complexity 132 146 +14
============================================
Files 45 46 +1
Lines 2358 2503 +145
Branches 370 393 +23
============================================
+ Hits 1852 1942 +90
- Misses 339 384 +45
- Partials 167 177 +10
|
@@ -0,0 +1,393 @@ | |||
package io.kaoto.backend.api.resource.v2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I copied the v1
file here thinking at some point we will deprecate and remove v1
and its tests.
At the end the round trip function.
var to = (Map<String, Object>) ((Map<String, Object>) steps.get(0)).get("to"); | ||
assertEquals("log:", to.get("uri")); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the fun part for this PR
|
||
assertEquals(res0.extract().body().asString(), res1.extract().body().asString()); | ||
|
||
var flows = Arrays.asList(res1.extract().body().as(Integration[].class)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that now we return a list/array of Integrations.
@@ -0,0 +1,2798 @@ | |||
[ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JSON responses now are arrays/lists, not single objects. So I had to copy some resources files and added the multi
string to distinguish.
uploadMode: '{{uploadMode}}' | ||
accessToken: '{{accessToken}}' | ||
|
||
--- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😈 multi Kamelets on the same file MUAHAHAHA
...ckend/api/service/deployment/generator/camelroute/IntegrationDeploymentGeneratorService.java
Show resolved
Hide resolved
@@ -107,6 +121,12 @@ public boolean appliesTo(final List<Step> steps) { | |||
.anyMatch(Predicate.isEqual(s.getKind().toUpperCase()))); | |||
} | |||
|
|||
@Override | |||
public boolean appliesToFlows(List<StepParserService.ParseResult<Step>> flows) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If one of the flows in the list of flows is from this DSL we assume that we can handle it.
...in/java/io/kaoto/backend/api/service/step/parser/camelroute/CamelRouteStepParserService.java
Show resolved
Hide resolved
@Override | ||
public List<ParseResult<Step>> getParsedFlows(String input) { | ||
var res = new LinkedList<ParseResult<Step>>(); | ||
String[] splitCRDs = input.split(System.lineSeparator() + "---" + System.lineSeparator()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this is too weak? Not sure how to make it better, to be honest. This could be in the middle of a long string text. Evil people will do evil things, you know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, haters gonna hate, I know... Would something like this help?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me try :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really working as expected.
@@ -118,7 +118,7 @@ public void populateKamelet( | |||
def.setTitle(String.valueOf(map.getOrDefault("title", ""))); | |||
def.setDescription(String.valueOf(map.getOrDefault("description", ""))); | |||
def.setRequired((List<String>) map.getOrDefault("required", null)); | |||
def.setProperties((Map<String, KameletDefinitionProperty>) map.getOrDefault("required", null)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Caught this bug while adding more kamel examples. Oopsie.
@@ -104,7 +105,12 @@ public String parse(final List<Step> steps, | |||
spec.setSteps(null); | |||
} | |||
|
|||
KameletBinding binding = new KameletBinding(String.valueOf(metadata.getOrDefault("name", "")), spec); | |||
var name = ""; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, we were not very careful and just trusted that things were not null. Naive us.
public String parse(List<StepParserService.ParseResult<Step>> flows) { | ||
StringBuilder sb = new StringBuilder(); | ||
flows.stream().forEachOrdered(stepParseResult -> { | ||
if (!sb.isEmpty()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simple but effective.
@@ -211,6 +212,36 @@ public Node representData(final Object data) { | |||
DumperOptions.FlowStyle.BLOCK); | |||
} | |||
}); | |||
|
|||
this.multiRepresenters.put(KameletDefinitionProperty.class, | |||
new RepresentMap() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was also missing, dumb us.
@@ -55,8 +56,20 @@ public interface DeploymentGeneratorService { | |||
* If applies, the name will be the name used on the integration deployed. | |||
*/ | |||
@WithSpan | |||
String parse(List<Step> steps, Map<String, Object> metadata, | |||
List<Parameter> parameters); | |||
@Deprecated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
deprecated because we should discourage its use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
Just to confirm:
1. Response shape
given the following YAML
- from:
uri: null
steps:
- aggregate:
aggregation-strategy: aggregate
- from:
uri: null
steps: []
- from:
uri: null
steps: []
we receive an array of routes, which is what I would expect to receive, but just wanted to confirm if this is correct or I should expect an object as you mentioned in another conversation?
2. YAML format
Sending 2 integrations in an array, we get the following routes:
would be possible / appropriate / useful to give an empty line between the routes? this is extremely 💅 (stylish)
@Consumes(MediaType.APPLICATION_JSON) | ||
@Produces("text/yaml") | ||
@Path("/") | ||
@CacheResult(cacheName = "api") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How would this cache behave? Is this the correct "doc" for this annotation?
@Override | ||
public List<ParseResult<Step>> getParsedFlows(String input) { | ||
var res = new LinkedList<ParseResult<Step>>(); | ||
String[] splitCRDs = input.split(System.lineSeparator() + "---" + System.lineSeparator()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, haters gonna hate, I know... Would something like this help?
BTW, almost forgot, as soon as we get this merged, I'll switch the UI to use the new endpoints and interact only with the first route in the array. After that, I'll start incorporating individual functionality into the multi-route support. |
You like danger 😸 Living on the edge! |
Added an object wrapper to return instead of a plain array of flows. You were right. |
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
Alright, now it sends and receives an object like this: {
"flows": [ ... ],
"properties: { ... }
} |
Adding an extra line between routes is breaking tests in an ugly way. I will leave that for a second PR. |
With the new endpoints introduced by KaotoIO/kaoto-backend#638, we could start wiring up the source code editor and the related components to use the multiple flows approach. Changes This pull request replaces the previous v1/integrations endpoint with the new v2/integrations endpoint that supports multiple flows. All the changes were validated against the existing e2e tests to ensure that the previous functionality from the single flow is still in place. * chore: Fix settings.js e2e test * chore: Fix editing.cy.js e2e test * chore: Fix step_integration.cy.js e2e test * chore: Fix source_code.cy.js e2e test * chore: Fix deleting_steps.cy.js e2e test * chore: Fix catalog_actions.cy.js e2e test * chore: Fix code_editor_actions.cy.js e2e test * chore: Fix step_actions_from_canvas.cy.js e2e test * chore: Fix step_extension_actions_from_canvas.cy.js e2e test * chore: Fix branches_from_canvas.cy.js e2e test * chore: Fix branches_step_actions_from_canvas.cy.js e2e test * chore: Fix nested_branches_from_canvas.cy.js e2e test * chore: Fix nested_branches_step_actions_from_canvas.cy.js e2e test relates to: #801
Backend has now an experimental
v2
api that supports multiroutes. Not all endpoints are ported fromv1
yet.Integration kind is not fully supported yet. This PR focused on Camel Routes, Kamelets, and Bindings.
Mixing different DSLs on the same file is not supported.
Superseeds #633