diff --git a/conf-template/starport.conf b/conf-template/starport.conf index b968ce2..82a86dc 100644 --- a/conf-template/starport.conf +++ b/conf-template/starport.conf @@ -34,7 +34,7 @@ krux.starport { EXAMPLE_ENVIRONMENT_VAR_2 = "some-value" } - # slack webhook to be used + # slack webhook to be used (optional) slack_webhook_url = ??? # graphite integration diff --git a/starport-core/src/main/scala/com/krux/starport/config/StarportSettings.scala b/starport-core/src/main/scala/com/krux/starport/config/StarportSettings.scala index 33f7349..a6b313a 100644 --- a/starport-core/src/main/scala/com/krux/starport/config/StarportSettings.scala +++ b/starport-core/src/main/scala/com/krux/starport/config/StarportSettings.scala @@ -4,11 +4,12 @@ import java.net.URL import scala.collection.JavaConverters._ import scala.collection.{Map => IMap} +import scala.util.Try import com.typesafe.config.{Config, ConfigFactory, ConfigValueType} -import com.krux.starport.net.StarportURLStreamHandlerFactory import com.krux.starport.metric.MetricSettings +import com.krux.starport.net.StarportURLStreamHandlerFactory class StarportSettings(val config: Config) extends Serializable { @@ -35,7 +36,7 @@ class StarportSettings(val config: Config) extends Serializable { v.unwrapped.asInstanceOf[String] } - val slackWebhookURL: String = config.getString("krux.starport.slack_webhook_url") + val slackWebhookURL: Option[String] = Try(config.getString("krux.starport.slack_webhook_url")).toOption } diff --git a/starport-core/src/main/scala/com/krux/starport/db/tool/SubmitPipeline.scala b/starport-core/src/main/scala/com/krux/starport/db/tool/SubmitPipeline.scala index b75f9e6..c2fa56d 100644 --- a/starport-core/src/main/scala/com/krux/starport/db/tool/SubmitPipeline.scala +++ b/starport-core/src/main/scala/com/krux/starport/db/tool/SubmitPipeline.scala @@ -23,6 +23,8 @@ object SubmitPipeline extends DateTimeFunctions with WaitForIt with DateTimeMapp private val ValidEmail = """^([a-zA-Z0-9.!#$%&’'*+/=?^_`{|}~-]+)@([a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*)$""".r + lazy val starportSettings = StarportSettings() + case class Options( jar: String = "", pipelineObject: String = "", @@ -48,19 +50,21 @@ object SubmitPipeline extends DateTimeFunctions with WaitForIt with DateTimeMapp pipelineDef.getField("MODULE$").get(null).asInstanceOf[DataPipelineDefGroup].schedule.asInstanceOf[RecurringSchedule] } - private def sendSlackNotification(message: String) = { - logger.info("Sending Slack Notification") - - SendSlackMessage( - webhookUrl = StarportSettings().slackWebhookURL, - message = Seq( - "Pipeline " + message, - ":robot_face: StarportScheduler", - "Requested By: " + System.getProperties().get("user.name").toString() - ), - user = Option("starport"), - channel = Option("#robots") - ) + private def sendSlackNotification(message: String) = starportSettings.slackWebhookURL match { + case Some(webhook) => + logger.info("Sending Slack Notification") + SendSlackMessage( + webhookUrl = webhook, + message = Seq( + "Pipeline " + message, + ":robot_face: StarportScheduler", + "Requested By: " + System.getProperties().get("user.name").toString() + ), + user = Option("starport"), + channel = Option("#robots") + ) + case None => + logger.warn("krux.starport.slack_webhook_url not configured, skip sending slack notification") } def main(args: Array[String]): Unit = { @@ -150,7 +154,7 @@ object SubmitPipeline extends DateTimeFunctions with WaitForIt with DateTimeMapp println("Dry Run. Skip sending the querys...") dryRunOutput } else { - val db = StarportSettings().jdbc.db + val db = starportSettings.jdbc.db db.run(query).waitForResult } } diff --git a/version.sbt b/version.sbt index 5797fe6..8ca0de4 100644 --- a/version.sbt +++ b/version.sbt @@ -1 +1 @@ -version in ThisBuild := "5.0.0" +version in ThisBuild := "5.0.1"