Skip to content
This repository was archived by the owner on Nov 18, 2021. It is now read-only.

enable newly deployed deployment if it is disabled implementing #3 #5

Merged
merged 1 commit into from
Oct 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jetbrains.kotlin.serialization.js.DynamicTypeDeserializer.id

group = "com.mkring.wildlydeplyplugin"
version = "0.2.6"
version = "0.2.7-SNAPSHOT"

plugins {
kotlin("jvm") version "1.2.61"
Expand Down
21 changes: 20 additions & 1 deletion src/main/kotlin/com/mkring/wildlydeplyplugin/FileDeployer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ class FileDeployer(
val file: String?, val host: String, val port: Int, val user: String?, val password: String?,
val reload: Boolean, val force: Boolean, val name: String?, val runtimeName: String?, val awaitReload: Boolean
) {

fun deploy() {
println("deploy(): " + this)
checkHostDns()
Expand All @@ -41,6 +40,9 @@ class FileDeployer(
println("given $file existent: ${File(file).isFile}")
val deploySuccess = cli.cmd("deploy $force $name $runtimeName $file").isSuccess
println("deploy success: $deploySuccess")

enableDeploymentIfNecessary(name)

if (reload) {
try {
val reloadSuccess = cli.cmd("reload").isSuccess
Expand All @@ -61,6 +63,23 @@ class FileDeployer(

}

private fun enableDeploymentIfNecessary(name: String) {
println("\nchecking if deployment is enabled...")
val deploymentEnabled =
blockingCmd("deployment-info", 2, ChronoUnit.MINUTES).response.get("result").asList().map {
it.asProperty().name to it.getParam("enabled").removePrefix("enabled: ")
}.firstOrNull {
it.first == name.removePrefix("--name=")
}?.second?.toBoolean()

if (deploymentEnabled == false) {
println("not enabled! going to enable now!")
blockingCmd("deploy $name", 2, ChronoUnit.MINUTES).response.also {
println("enable response: $it\n")
}
}
}

private fun connect(cli: CLI) {
cli.connect(host, port, user, password?.toCharArray())
}
Expand Down