Skip to content
This repository has been archived by the owner on Nov 27, 2023. It is now read-only.

feature: Use DSL included in the body instead of param #685

Merged
merged 1 commit into from
Jun 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,8 @@ public void setDslSpecifications(final Instance<DSLSpecification> dslSpecificati
@CacheResult(cacheName = "api")
@Operation(summary = "Get CRDs",
description = "Returns the associated custom resource definitions. This is an idempotent operation.")
public String crds(
final @RequestBody FlowsWrapper request,
final @Parameter(description = "DSL to use. For example: 'Kamelet Binding'.")
@QueryParam("dsl") String dsl) {
return deploymentService.crds(request.flows(), request.metadata(), dsl);
public String crds(final @RequestBody FlowsWrapper request) {
return deploymentService.crds(request.flows(), request.metadata());
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,21 +111,28 @@ public String crd(final Integration i, final String dsl) {

/*
* 🐱method crds: String
* 🐱param i: List<Integration>
* 🐱param integrationList: List<Integration>
* 🐱param dsl: String
*
* Based on the provided steps, return a valid yaml string to deploy
*/
@WithSpan
public String crds(final List<Integration> i, final Map<String, Object> metadata, final String dsl) {
public String crds(final List<Integration> integrationList, final Map<String, Object> metadata) {
List<StepParserService.ParseResult<Step>> integrations = new LinkedList<>();
String dsl = null;

for (Integration integration : i) {
for (Integration integration : integrationList) {
var parseResult = new StepParserService.ParseResult<Step>();
parseResult.setMetadata(integration.getMetadata());
parseResult.setSteps(integration.getSteps());
parseResult.setParameters(integration.getParameters());
integrations.add(parseResult);
if (integration.getDsl() != null) {
if (dsl != null && !integration.getDsl().equalsIgnoreCase(dsl)) {
log.error("We were sent a mix of DSL in the same list of flows!");
}
dsl = integration.getDsl();
}
}

if (metadata != null && !metadata.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ void amqAmq() throws Exception {

res = given()
.when()
.contentType("application/json")
.contentType(MediaType.APPLICATION_JSON)
.body(json)
.post("?dsl=Camel Route")
.post()
.then()
.statusCode(Response.Status.OK.getStatusCode());

Expand All @@ -90,9 +90,9 @@ void amqAmqFromJson() throws Exception {

var res = given()
.when()
.contentType("application/json")
.contentType(MediaType.APPLICATION_JSON)
.body(json)
.post("?dsl=Camel Route")
.post()
.then()
.statusCode(Response.Status.OK.getStatusCode());

Expand Down Expand Up @@ -139,9 +139,9 @@ void newBranchStep() throws Exception {
.toURI()));
var res = given()
.when()
.contentType("application/json")
.contentType(MediaType.APPLICATION_JSON)
.body(json)
.post("?dsl=Camel Route")
.post()
.then()
.statusCode(Response.Status.OK.getStatusCode());
Yaml yaml = new Yaml(new Constructor(KameletBinding.class), new KameletRepresenter());
Expand All @@ -154,9 +154,9 @@ void scriptStep() throws Exception {
IntegrationsResourceTest.class.getResource("../../resource/script-multi.json").toURI()));
var res = given()
.when()
.contentType("application/json")
.contentType(MediaType.APPLICATION_JSON)
.body(json)
.post("?dsl=Camel Route")
.post()
.then()
.statusCode(Response.Status.OK.getStatusCode());
String yaml = res.extract().body().asString();
Expand Down Expand Up @@ -196,9 +196,9 @@ void expressionObject() throws Exception {

res = given()
.when()
.contentType("application/json")
.contentType(MediaType.APPLICATION_JSON)
.body(json)
.post("?dsl=Camel Route")
.post()
.then()
.statusCode(Response.Status.OK.getStatusCode());

Expand Down Expand Up @@ -272,9 +272,9 @@ void kameletUri() throws Exception {

res = given()
.when()
.contentType("application/json")
.contentType(MediaType.APPLICATION_JSON)
.body(json)
.post("?dsl=Camel Route")
.post()
.then()
.statusCode(Response.Status.OK.getStatusCode());

Expand Down Expand Up @@ -318,9 +318,9 @@ void noFrom() throws Exception {
IntegrationsResourceTest.class.getResource("../../resource/no-from-multi.json").toURI()));
var res = given()
.when()
.contentType("application/json")
.contentType(MediaType.APPLICATION_JSON)
.body(json)
.post("?dsl=Camel Route")
.post()
.then()
.statusCode(Response.Status.OK.getStatusCode());
var yaml = res.extract().body().asString();
Expand Down Expand Up @@ -372,7 +372,7 @@ void roundTrip(String file) throws IOException {
.when()
.contentType(MediaType.APPLICATION_JSON)
.body(flows)
.post("?dsl=" + parameters[0])
.post()
.then()
.statusCode(Response.Status.OK.getStatusCode());
var sourceCode = res2.extract().body().asString();
Expand Down