asimov-deploy-ui
Advanced tools
Comparing version 0.10.2 to 0.10.3
var https = require('https'); | ||
var _ = require('underscore'); | ||
@@ -10,3 +11,3 @@ var _colors = { | ||
var _eventNames = { | ||
var _slackDisplayEventNames = { | ||
startDeployLifecycleCommand: 'releasing', | ||
@@ -17,2 +18,9 @@ completeDeployLifecycleCommand: 'finished', | ||
var _lifeCycleNames = { | ||
startDeployLifecycleCommand: 'started', | ||
completeDeployLifecycleCommand: 'completed', | ||
cancelDeployLifecycleCommand: 'cancelled' | ||
}; | ||
function postToSlack(urlToken, body) { | ||
@@ -49,6 +57,7 @@ var postData = JSON.stringify(body); | ||
var featureToggle = require('./../feature-toggle').create(config); | ||
var slackConfig = featureToggle.getActiveFeature('Slack'); | ||
var lifecycleConfig = featureToggle.getActiveFeature('lifecycleControls') || {}; | ||
var slackConfig = lifecycleConfig.Slack || {}; | ||
this.send = function (eventName, eventBody, deployId) { | ||
if (slackConfig.enabled !== true) { | ||
if (lifecycleConfig.enabled !== true) { | ||
return; | ||
@@ -62,3 +71,4 @@ } | ||
var slackEventName = _eventNames[eventName]; | ||
var lifeCycleEventName = _lifeCycleNames[eventName]; | ||
var slackEventName = _slackDisplayEventNames[eventName]; | ||
var username = deployData.user; | ||
@@ -80,3 +90,8 @@ var title = deployData.data.title; | ||
postToSlack(slackConfig.urlToken, body); | ||
for (var i = slackConfig.channels.length - 1; i >= 0; i--) { | ||
var channel = slackConfig.channels[i]; | ||
if (_.contains(channel.events, lifeCycleEventName)){ | ||
postToSlack(channel.urlToken, body); | ||
} | ||
} | ||
}; | ||
@@ -83,0 +98,0 @@ }; |
@@ -29,3 +29,15 @@ { | ||
"lifecycleControls": { | ||
"enabled": true | ||
"enabled": true, | ||
"Slack": { | ||
"channels": [ | ||
{ | ||
"urlToken": "T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX", | ||
"events": ["started", "completed", "cancelled"] | ||
}, | ||
{ | ||
"urlToken": "T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX", | ||
"events": ["completed"] | ||
} | ||
] | ||
} | ||
}, | ||
@@ -39,6 +51,2 @@ "deployAnnotations": { | ||
"enabled" : true | ||
}, | ||
"Slack": { | ||
"urlToken": "T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX", | ||
"enabled" : false | ||
} | ||
@@ -45,0 +53,0 @@ }, |
@@ -5,3 +5,3 @@ { | ||
"author": "Ebay Inc", | ||
"version": "0.10.2", | ||
"version": "0.10.3", | ||
"homepage": "https://github.com/asimov-deploy/asimov-deploy", | ||
@@ -8,0 +8,0 @@ "license": "Apache-2.0", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3412802
71545