Skip to content

Commit

Permalink
feat(web) disabling front50 refresh when orca fetches pipeline (#1598)
Browse files Browse the repository at this point in the history
  • Loading branch information
emjburns authored and ajordens committed Sep 6, 2017
1 parent da91c95 commit 98fc206
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ interface Front50Service {
@GET("/pipelines/{applicationName}")
List<Map<String, Object>> getPipelines(@Path("applicationName") String applicationName)

@GET("/pipelines/{applicationName}")
List<Map<String, Object>> getPipelines(@Path("applicationName") String applicationName, @Query("refresh") boolean refresh)

@POST("/pipelines")
Response savePipeline(@Body Map pipeline)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public EnabledPipelineValidator(Optional<Front50Service> front50Service) {
if (front50Service == null) {
throw new UnsupportedOperationException("Front50 not enabled, no way to validate pipeline. Fix this by setting front50.enabled: true");
}
List<Map<String, Object>> pipelines = isStrategy(pipeline) ? front50Service.getStrategies(pipeline.getApplication()) : front50Service.getPipelines(pipeline.getApplication());
List<Map<String, Object>> pipelines = isStrategy(pipeline) ? front50Service.getStrategies(pipeline.getApplication()) : front50Service.getPipelines(pipeline.getApplication(), false);
pipelines
.stream()
.filter(it -> it.get("id").equals(pipeline.getPipelineConfigId()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class StartPipelineTask implements Task {
String pipelineId = stage.context.pipelineId ?: stage.context.pipeline
Boolean isStrategy = stage.context.pipelineParameters?.strategy ?: false

List<Map<String, Object>> pipelines = isStrategy ? front50Service.getStrategies(application) : front50Service.getPipelines(application)
List<Map<String, Object>> pipelines = isStrategy ? front50Service.getStrategies(application) : front50Service.getPipelines(application, false)
Map<String, Object> pipelineConfig = pipelines.find { it.id == pipelineId }

if (!pipelineConfig) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class EnabledPipelineValidatorSpec extends Specification {

def "allows one-off pipeline to run"() {
given:
front50Service.getPipelines(execution.application) >> []
front50Service.getPipelines(execution.application, false) >> []

when:
validator.checkRunnable(execution)
Expand All @@ -47,7 +47,7 @@ class EnabledPipelineValidatorSpec extends Specification {

def "allows enabled pipeline to run"() {
given:
front50Service.getPipelines(execution.application) >> [
front50Service.getPipelines(execution.application, false) >> [
[id: execution.pipelineConfigId, application: execution.application, name: "whatever", disabled: false]
]

Expand All @@ -66,7 +66,7 @@ class EnabledPipelineValidatorSpec extends Specification {

def "prevents disabled pipeline from running"() {
given:
front50Service.getPipelines(execution.application) >> [
front50Service.getPipelines(execution.application, false) >> [
[id: execution.pipelineConfigId, application: execution.application, name: "whatever", disabled: true]
]

Expand Down Expand Up @@ -125,7 +125,7 @@ class EnabledPipelineValidatorSpec extends Specification {

def "doesn't choke on non-boolean strategy value"() {
given:
front50Service.getPipelines(execution.application) >> [
front50Service.getPipelines(execution.application, false) >> [
[id: execution.pipelineConfigId, application: execution.application, name: "whatever", disabled: false]
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public String interpret(TagNode tagNode, JinjavaInterpreter interpreter) {
throw new TemplateSyntaxException(tagNode.getMaster().getImage(), "Tag 'pipelineId' is missing required fields: " + helper, tagNode.getLineNumber());
}

List<Map<String, Object>> pipelines = Optional.ofNullable(front50Service.getPipelines(application)).orElse(Collections.emptyList());
List<Map<String, Object>> pipelines = Optional.ofNullable(front50Service.getPipelines(application, false)).orElse(Collections.emptyList());

Map<String, Object> result = pipelines
.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class PipelineIdTagSpec extends Specification {
@Unroll
def 'should render pipeline id'() {
given:
front50Service.getPipelines('myApp') >> [
front50Service.getPipelines('myApp', false) >> [
[
name: 'Bake and Tag',
application: 'myApp',
Expand Down Expand Up @@ -86,7 +86,7 @@ class PipelineIdTagSpec extends Specification {
renderer.render('{% pipelineId name="Bake and Tag" %}', context)

then: 'application should be inferred from context'
1 * front50Service.getPipelines(applicationInContext) >> [
1 * front50Service.getPipelines(applicationInContext, false) >> [
[
name: 'Bake and Tag',
application: 'myApp',
Expand All @@ -111,7 +111,7 @@ class PipelineIdTagSpec extends Specification {
renderer.render('{% pipelineId name="Bake and Tag" %}', context)

then:
1 * front50Service.getPipelines(applicationInContext) >> []
1 * front50Service.getPipelines(applicationInContext, false) >> []
thrown(TemplateRenderException)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ class TaskController {
statuses: (statuses.split(",") as Collection)
)

def pipelineConfigIds = front50Service.getPipelines(application)*.id as List<String>
def pipelineConfigIds = front50Service.getPipelines(application, false)*.id as List<String>
def strategyConfigIds = front50Service.getStrategies(application)*.id as List<String>
def allIds = pipelineConfigIds + strategyConfigIds

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ class TaskControllerSpec extends Specification {
pipelineConfigId = config.pipelineConfigId
}
})
front50Service.getPipelines(app) >> [[id: "1"], [id: "2"]]
front50Service.getPipelines(app, false) >> [[id: "1"], [id: "2"]]
front50Service.getStrategies(app) >> []

when:
Expand Down

0 comments on commit 98fc206

Please sign in to comment.