pcimcioch.gitlabci.dsl.job.ImageDsl.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gitlab-ci-kotlin-dsl Show documentation
Show all versions of gitlab-ci-kotlin-dsl Show documentation
Library providing Kotlin DSL to configure GitlabCI file
package pcimcioch.gitlabci.dsl.job
import kotlinx.serialization.Serializable
import pcimcioch.gitlabci.dsl.DslBase
@Serializable
class ImageDsl(
var name: String? = null
) : DslBase() {
var entrypoint: MutableList? = null
fun entrypoint(vararg elements: String) = entrypoint(elements.toList())
fun entrypoint(elements: Iterable) = ensureEntrypoint().addAll(elements)
override fun validate(errors: MutableList) {
addError(errors, isEmpty(name), "[image] name '$name' is incorrect")
}
private fun ensureEntrypoint() = entrypoint ?: mutableListOf().also { entrypoint = it }
companion object {
init {
addSerializer(ImageDsl::class, serializer())
}
}
}
fun createImage(name: String? = null, block: ImageDsl.() -> Unit = {}) = ImageDsl(name).apply(block)