ai.digital.integration.server.common.extension.CommonIntegrationServerExtension.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of integration-server-gradle-plugin Show documentation
Show all versions of integration-server-gradle-plugin Show documentation
The easy way to get custom setup for Deploy up and running
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())
}