-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
19d54d0
commit 44c6acd
Showing
42 changed files
with
688 additions
and
263 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
...xtension/environments/workflows/executors/SlotPipelineDeployedWorkflowNodeExecutorData.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package net.nemerosa.ontrack.extension.environments.workflows.executors | ||
|
||
/** | ||
* Just a marker for the documentation | ||
*/ | ||
class SlotPipelineDeployedWorkflowNodeExecutorData |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
...tension/environments/workflows/executors/SlotPipelineDeployingWorkflowNodeExecutorData.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package net.nemerosa.ontrack.extension.environments.workflows.executors | ||
|
||
/** | ||
* Just a marker for the documentation | ||
*/ | ||
class SlotPipelineDeployingWorkflowNodeExecutorData |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
.../nemerosa/ontrack/extension/notifications/schema/NotificationDynamicJsonSchemaProvider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package net.nemerosa.ontrack.extension.notifications.schema | ||
|
||
import net.nemerosa.ontrack.extension.notifications.channels.NotificationChannel | ||
import net.nemerosa.ontrack.model.annotations.getAPITypeDescription | ||
import net.nemerosa.ontrack.model.docs.Documentation | ||
import net.nemerosa.ontrack.model.json.schema.DynamicJsonSchemaProvider | ||
import net.nemerosa.ontrack.model.json.schema.JsonType | ||
import net.nemerosa.ontrack.model.json.schema.JsonTypeBuilder | ||
import org.springframework.stereotype.Component | ||
import kotlin.reflect.full.findAnnotation | ||
import kotlin.reflect.full.starProjectedType | ||
|
||
@Component | ||
class NotificationDynamicJsonSchemaProvider( | ||
private val channels: List<NotificationChannel<*, *>>, | ||
) : DynamicJsonSchemaProvider { | ||
|
||
override val discriminatorValues: List<String> | ||
get() = channels.map { it.type } | ||
|
||
override fun getConfigurationTypes(builder: JsonTypeBuilder): Map<String, JsonType> = | ||
channels.associate { channel -> | ||
channel.type to getConfigurationType(channel, builder) | ||
} | ||
|
||
private fun getConfigurationType( | ||
channel: NotificationChannel<*, *>, | ||
builder: JsonTypeBuilder, | ||
): JsonType { | ||
val docClass = channel::class.findAnnotation<Documentation>() | ||
?: error("${channel::class} does not have a Documentation annotation") | ||
return builder.toType( | ||
type = docClass.value.starProjectedType, | ||
description = getAPITypeDescription(channel::class) | ||
) | ||
} | ||
|
||
override fun toRef(id: String): String = "notification-config-$id" | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
...nemerosa/ontrack/extension/workflows/notifications/WorkflowNotificationChannelNodeData.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...java/net/nemerosa/ontrack/extension/workflows/schema/WorkflowDynamicJsonSchemaProvider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package net.nemerosa.ontrack.extension.workflows.schema | ||
|
||
import net.nemerosa.ontrack.extension.workflows.execution.WorkflowNodeExecutor | ||
import net.nemerosa.ontrack.model.annotations.getAPITypeDescription | ||
import net.nemerosa.ontrack.model.docs.Documentation | ||
import net.nemerosa.ontrack.model.json.schema.DynamicJsonSchemaProvider | ||
import net.nemerosa.ontrack.model.json.schema.JsonType | ||
import net.nemerosa.ontrack.model.json.schema.JsonTypeBuilder | ||
import org.springframework.stereotype.Component | ||
import kotlin.reflect.full.findAnnotation | ||
import kotlin.reflect.full.starProjectedType | ||
|
||
@Component | ||
class WorkflowDynamicJsonSchemaProvider( | ||
private val workflowNodeExecutors: List<WorkflowNodeExecutor>, | ||
) : DynamicJsonSchemaProvider { | ||
|
||
override val discriminatorValues: List<String> | ||
get() = workflowNodeExecutors.map { it.id } | ||
|
||
override fun getConfigurationTypes(builder: JsonTypeBuilder): Map<String, JsonType> = | ||
workflowNodeExecutors.associate { executor -> | ||
executor.id to getConfigurationType(executor, builder) | ||
} | ||
|
||
override fun toRef(id: String): String = "workflow-node-executor-$id" | ||
|
||
private fun getConfigurationType( | ||
executor: WorkflowNodeExecutor, | ||
builder: JsonTypeBuilder, | ||
): JsonType { | ||
val docClass = executor::class.findAnnotation<Documentation>() | ||
?: error("${executor::class} does not have a Documentation annotation") | ||
return builder.toType( | ||
type = docClass.value.starProjectedType, | ||
description = getAPITypeDescription(executor::class) | ||
) | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
...src/main/java/net/nemerosa/ontrack/extension/workflows/schema/WorkflowSchemaController.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
...est/java/net/nemerosa/ontrack/kdsl/acceptance/tests/workflows/ACCDSLWorkflowJSONSchema.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package net.nemerosa.ontrack.kdsl.acceptance.tests.workflows | ||
|
||
import net.nemerosa.ontrack.kdsl.acceptance.tests.AbstractACCDSLTestSupport | ||
import net.nemerosa.ontrack.kdsl.spec.extension.workflows.workflows | ||
import org.junit.jupiter.api.Test | ||
import kotlin.test.assertEquals | ||
|
||
class ACCDSLWorkflowJSONSchema : AbstractACCDSLTestSupport() { | ||
|
||
@Test | ||
fun `Downloading the JSON schema for workflows`() { | ||
val schema = ontrack.workflows.downloadJsonSchema() | ||
assertEquals( | ||
"#/\$defs/workflow", | ||
schema.path("\$ref").asText() | ||
) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
ontrack-model/src/main/java/net/nemerosa/ontrack/model/json/schema/AbstractJsonBaseType.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package net.nemerosa.ontrack.model.json.schema | ||
|
||
abstract class AbstractJsonBaseType( | ||
val type: String, | ||
description: String? | ||
) : AbstractJsonDescribedType(description) |
8 changes: 8 additions & 0 deletions
8
...k-model/src/main/java/net/nemerosa/ontrack/model/json/schema/AbstractJsonDescribedType.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package net.nemerosa.ontrack.model.json.schema | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude | ||
|
||
abstract class AbstractJsonDescribedType( | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
val description: String?, | ||
) : AbstractJsonType() |
7 changes: 7 additions & 0 deletions
7
ontrack-model/src/main/java/net/nemerosa/ontrack/model/json/schema/AbstractJsonNamedType.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package net.nemerosa.ontrack.model.json.schema | ||
|
||
abstract class AbstractJsonNamedType( | ||
val title: String, | ||
type: String, | ||
description: String?, | ||
) : AbstractJsonBaseType(type, description) |
3 changes: 3 additions & 0 deletions
3
ontrack-model/src/main/java/net/nemerosa/ontrack/model/json/schema/AbstractJsonType.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package net.nemerosa.ontrack.model.json.schema | ||
|
||
abstract class AbstractJsonType : JsonType |
Oops, something went wrong.