Skip to content

Commit

Permalink
feat(pipeline): add endpoint for evaluating pipeline expressions (#391)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielpeach committed May 11, 2017
1 parent 250f422 commit 64d68ad
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,19 @@ class PipelineController {
}
}

@ApiOperation(value = "Evaluate a pipeline expression using the provided execution as context")
@RequestMapping(value = "{id}/evaluateExpression")
Map evaluateExpressionForExecution(@PathVariable("id") String id,
@RequestParam("expression") String pipelineExpression) {
try {
pipelineService.evaluateExpressionForExecution(id, pipelineExpression)
} catch (RetrofitError e) {
if (e.response?.status == 404) {
throw new PipelineNotFoundException()
}
}
}

@ResponseStatus(HttpStatus.NOT_FOUND)
@InheritConstructors
static class PipelineNotFoundException extends RuntimeException {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ class PipelineService {
orcaService.restartPipelineStage(executionId, stageId, context)
}

Map evaluateExpressionForExecution(String executionId, String pipelineExpression) {
orcaService.evaluateExpressionForExecution(executionId, pipelineExpression)
}

@InheritConstructors
@ResponseStatus(value = HttpStatus.NOT_FOUND, reason = "pipeline config not found!")
static class PipelineConfigNotFoundException extends RuntimeException {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,8 @@ interface OrcaService {
@Headers("Accept: application/json")
@PATCH("/pipelines/{executionId}/stages/{stageId}")
Map updatePipelineStage(@Path("executionId") String executionId, @Path("stageId") String stageId, @Body Map context)

@Headers("Accept: application/json")
@GET("/pipelines/{id}/evaluateExpression")
Map evaluateExpressionForExecution(@Path("id") String executionId, @Query("expression") String pipelineExpression)
}

0 comments on commit 64d68ad

Please sign in to comment.