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

ai.digital.integration.server.common.extension.CommonIntegrationServerExtension.kt Maven / Gradle / Ivy

There is a newer version: 23.3.0-1025.941
Show newest version
package ai.digital.integration.server.common.extension

import ai.digital.integration.server.common.constant.ClusterProfileName
import ai.digital.integration.server.common.domain.Cluster
import ai.digital.integration.server.common.domain.Server
import ai.digital.integration.server.common.domain.profiles.*
import org.gradle.api.Action
import org.gradle.api.Project
import org.gradle.kotlin.dsl.container
import org.gradle.kotlin.dsl.newInstance
import org.gradle.kotlin.dsl.property

abstract class CommonIntegrationServerExtension(val project: Project) {

    val clusterProfiles: ProfileContainer =
        DefaultProfileContainer(project.container(Profile::class) { name ->
            when (name) {
                ClusterProfileName.DOCKER_COMPOSE.profileName ->
                    project.objects.newInstance(DockerComposeProfile::class, project)
                ClusterProfileName.OPERATOR.profileName ->
                    project.objects.newInstance(OperatorProfile::class, name, project)
                ClusterProfileName.TERRAFORM.profileName ->
                    project.objects.newInstance(TerraformProfile::class, name, project)
                ClusterProfileName.HELM.profileName ->
                    project.objects.newInstance(HelmProfile::class, name, project)
                else ->
                    throw IllegalArgumentException("Profile name `$name` is not supported. Choose one of ${
                        ClusterProfileName.values().joinToString { profileEnum -> profileEnum.profileName }
                    }")
            }

        })

    fun clusterProfiles(action: Action) = action.execute(clusterProfiles)

    val cluster = project.objects.property().value(Cluster(project.objects))

    fun cluster(action: Action) = action.execute(cluster.get())

    val operatorServer = project.objects.property().value(Server("operatorServer"))

    fun operatorServer(action: Action) = action.execute(operatorServer.get())
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy