Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core/notifications): Application-level pipeline notifications wer… #1269

Merged
merged 1 commit into from
Apr 7, 2017
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 @@ -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