Skip to content

Commit

Permalink
fix(notifier): Provide the types for mailClient and jiraClient
Browse files Browse the repository at this point in the history
Make sure that the types for `mailClient` and `jiraClient` are always
defined.

Signed-off-by: Martin Nonnenmacher <[email protected]>
  • Loading branch information
mnonnenmacher committed May 23, 2024
1 parent 2bfeec1 commit b8eb171
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions notifier/src/main/kotlin/Notifier.kt
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,20 @@ class Notifier(
) : ScriptRunner() {
private val customProperties = buildMap {
put("ortResult", ortResult)

config.mail?.let { put("mailClient", MailNotifier(it)) }
config.jira?.let { put("jiraClient", JiraNotifier(it)) }

put("mailClient", config.mail?.let { MailNotifier(it) })
put("jiraClient", config.jira?.let { JiraNotifier(it) })
put("resolutionProvider", resolutionProvider)
}

private val customPropertyTypes = mapOf(
"ortResult" to KotlinType(OrtResult::class),
"mailClient" to KotlinType(MailNotifier::class, isNullable = true),
"jiraClient" to KotlinType(JiraNotifier::class, isNullable = true),
"resolutionProvider" to KotlinType(ResolutionProvider::class)
)

override val compConfig = createJvmCompilationConfigurationFromTemplate<NotificationsScriptTemplate> {
providedProperties(customProperties.mapValues { (_, v) -> KotlinType(v::class) })
providedProperties(customPropertyTypes)
}

override val evalConfig = ScriptEvaluationConfiguration {
Expand Down

0 comments on commit b8eb171

Please sign in to comment.