Skip to content

Commit

Permalink
fix(core/notifications): Application-level pipeline notifications wer…
Browse files Browse the repository at this point in the history
…e not having their expressions evaluated. (#1269)
  • Loading branch information
Matt Duftler committed Apr 7, 2017
1 parent d210aae commit fefe9c6
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.netflix.spinnaker.orca.echo.config

import com.fasterxml.jackson.databind.ObjectMapper
import com.netflix.spinnaker.orca.front50.Front50Service
import groovy.transform.CompileStatic
import com.netflix.spinnaker.orca.echo.EchoService
Expand Down Expand Up @@ -45,6 +46,7 @@ class EchoConfiguration {

@Autowired RetrofitClient retrofitClient
@Autowired RestAdapter.LogLevel retrofitLogLevel
@Autowired ObjectMapper objectMapper

@Bean
Endpoint echoEndpoint(
Expand All @@ -71,7 +73,8 @@ class EchoConfiguration {

@Bean
EchoNotifyingExecutionListener echoNotifyingPipelineExecutionListener(EchoService echoService,
Front50Service front50Service) {
new EchoNotifyingExecutionListener(echoService, front50Service)
Front50Service front50Service,
ObjectMapper objectMapper) {
new EchoNotifyingExecutionListener(echoService, front50Service, objectMapper)
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.netflix.spinnaker.orca.echo.spring

import com.fasterxml.jackson.databind.ObjectMapper
import com.netflix.spinnaker.orca.front50.Front50Service

import com.netflix.spinnaker.orca.front50.model.ApplicationNotifications
import com.netflix.spinnaker.orca.pipeline.util.ContextParameterProcessor
import groovy.transform.CompileStatic
import groovy.util.logging.Slf4j
import com.netflix.spinnaker.orca.ExecutionStatus
Expand All @@ -20,9 +22,12 @@ class EchoNotifyingExecutionListener implements ExecutionListener {

private final Front50Service front50Service

EchoNotifyingExecutionListener(EchoService echoService, Front50Service front50Service) {
private final ObjectMapper objectMapper

EchoNotifyingExecutionListener(EchoService echoService, Front50Service front50Service, ObjectMapper objectMapper) {
this.echoService = echoService
this.front50Service = front50Service
this.objectMapper = objectMapper
}

@Override
Expand Down Expand Up @@ -89,6 +94,9 @@ class EchoNotifyingExecutionListener implements ExecutionListener {

if (notifications) {
notifications.getPipelineNotifications().each { appNotification ->
Map executionMap = objectMapper.convertValue(pipeline, Map)

appNotification = ContextParameterProcessor.process(appNotification, executionMap, false)

Map<String, Object> targetMatch = pipeline.notifications.find { pipelineNotification ->
pipelineNotification.address == appNotification.address && pipelineNotification.type == appNotification.type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.netflix.spinnaker.orca.echo.spring

import com.fasterxml.jackson.databind.ObjectMapper
import com.netflix.spinnaker.orca.TaskResult
import com.netflix.spinnaker.orca.batch.SpringBatchExecutionRunner
import com.netflix.spinnaker.orca.batch.TaskTaskletAdapterImpl
Expand Down Expand Up @@ -196,7 +197,7 @@ abstract class EchoEventIntegrationSpec<R extends ExecutionRunner> extends Speci

@Bean
EchoNotifyingExecutionListener echoNotifyingExecutionListener(EchoService echoService, Front50Service front50Service) {
new EchoNotifyingExecutionListener(echoService, front50Service)
new EchoNotifyingExecutionListener(echoService, front50Service, new ObjectMapper())
}

@Bean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.netflix.spinnaker.orca.echo.spring

import com.fasterxml.jackson.databind.ObjectMapper
import com.netflix.spinnaker.orca.ExecutionStatus
import com.netflix.spinnaker.orca.echo.EchoService
import com.netflix.spinnaker.orca.front50.Front50Service
Expand All @@ -30,9 +31,10 @@ class EchoNotifyingExecutionListenerSpec extends Specification {

def echoService = Mock(EchoService)
def front50Service = Mock(Front50Service)
def objectMapper = new ObjectMapper()

@Subject
def echoListener = new EchoNotifyingExecutionListener(echoService, front50Service)
def echoListener = new EchoNotifyingExecutionListener(echoService, front50Service, objectMapper)

@Shared
ApplicationNotifications notifications = new ApplicationNotifications()
Expand Down

0 comments on commit fefe9c6

Please sign in to comment.