Skip to content

Commit b4337a5

Browse files
committed
fix utterly broken deprecation warnings
1 parent a73789e commit b4337a5

File tree

1 file changed

+25
-19
lines changed

1 file changed

+25
-19
lines changed

engine/src/main/scala/cromwell/webservice/PartialWorkflowSources.scala

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import _root_.io.circe.yaml
44
import akka.util.ByteString
55
import cats.data.NonEmptyList
66
import cats.data.Validated.{Invalid, Valid}
7+
import cats.instances.option._
78
import cats.syntax.apply._
9+
import cats.syntax.functor._
810
import cats.syntax.validated._
911
import common.validation.ErrorOr.ErrorOr
1012
import common.validation.Validation._
@@ -68,12 +70,27 @@ object PartialWorkflowSources {
6870
// workflow source
6971
val wdlSource = getStringValue(WdlSourceKey)
7072
val workflowSource = getStringValue(WorkflowSourceKey)
71-
val wdlSourceWarning = wdlSource.map(_ => wdlSourceDeprecationWarning)
73+
74+
def deprecationWarning(out: String, in: String)(actual: String): String = {
75+
if (actual == out) {
76+
val warning =
77+
Array(
78+
s"The '$out' parameter name has been deprecated in favor of '$in'.",
79+
s"Support for '$out' will be removed from future versions of Cromwell.",
80+
s"Please switch to using '$in' in future submissions.").mkString(" ")
81+
log.warn(warning)
82+
warning
83+
} else ""
84+
}
85+
86+
val wdlSourceDeprecationWarning: String => String = deprecationWarning(out = WdlSourceKey, in = WorkflowSourceKey)
87+
val wdlSourceWarning = wdlSource.as(WdlSourceKey) map wdlSourceDeprecationWarning
88+
7289
val workflowSourceFinal: ErrorOr[String] = (wdlSource, workflowSource) match {
7390
case (Some(source), None) => source.validNel
7491
case (None, Some(source)) => source.validNel
75-
case (Some(_), Some(_)) => "wdlSource and workflowSource can't both be supplied".invalidNel
76-
case (None, None) => "workflowSource needs to be supplied".invalidNel
92+
case (Some(_), Some(_)) => s"$WdlSourceKey and $WorkflowSourceKey can't both be supplied".invalidNel
93+
case (None, None) => s"$WorkflowSourceKey needs to be supplied".invalidNel
7794
}
7895

7996
// workflow inputs
@@ -90,11 +107,14 @@ object PartialWorkflowSources {
90107
// dependencies
91108
val wdlDependencies = getArrayValue(WdlDependenciesKey)
92109
val workflowDependencies = getArrayValue(WorkflowDependenciesKey)
93-
val wdlDependenciesWarning = wdlDependencies.map(_ => wdlDependenciesDeprecationWarning)
110+
111+
val wdlDependenciesDeprecationWarning: String => String = deprecationWarning(out = "wdlDependencies", in = "workflowDependencies")
112+
val wdlDependenciesWarning = wdlDependencies.as(WdlDependenciesKey) map wdlDependenciesDeprecationWarning
113+
94114
val workflowDependenciesFinal: ErrorOr[Option[Array[Byte]]] = (wdlDependencies, workflowDependencies) match {
95115
case (Some(dep), None) => Option(dep).validNel
96116
case (None, Some(dep)) => Option(dep).validNel
97-
case (Some(_), Some(_)) => "wdlDependencies and workflowDependencies can't both be supplied".invalidNel
117+
case (Some(_), Some(_)) => s"$WdlDependenciesKey and $WorkflowDependenciesKey can't both be supplied".invalidNel
98118
case (None, None) => None.validNel
99119
}
100120

@@ -177,20 +197,6 @@ object PartialWorkflowSources {
177197
case Invalid(err) => err.invalid
178198
}
179199
}
180-
181-
private val wdlSourceDeprecationWarning = deprecationWarning(out = "wdlSource", in = "workflowSource")
182-
private val wdlDependenciesDeprecationWarning = deprecationWarning(out = "wdlDependencies", in = "workflowDependencies")
183-
184-
private def deprecationWarning(out: String, in: String): String = {
185-
val warning =
186-
s"""
187-
|The '$out' parameter name has been deprecated in favor of '$in'.
188-
|Support for '$out' will be removed from future versions of Cromwell.
189-
|Please switch to using '$in' in future submissions.
190-
""".stripMargin
191-
log.warn(warning)
192-
warning
193-
}
194200

195201
def mergeMaps(allInputs: Seq[Option[String]]): JsObject = {
196202
val convertToMap = allInputs.map(x => toMap(x))

0 commit comments

Comments
 (0)