All Downloads are FREE. Search and download functionalities are using the official Maven repository.

pcimcioch.gitlabci.dsl.job.ImageDsl.kt Maven / Gradle / Ivy

There is a newer version: 1.6.0
Show newest version
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)




© 2015 - 2024 Weber Informatics LLC | Privacy Policy