Skip to content
/ titan Public
forked from titan-data/titan

Commit

Permalink
Browse files Browse the repository at this point in the history
Signed-off-by: Derek Smart <[email protected]>
  • Loading branch information
Derek Smart committed Oct 22, 2019
1 parent c4533b6 commit 768b587
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/main/kotlin/io/titandata/titan/clients/Docker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ class Docker(private val executor: CommandExecutor) {
return executor.exec(listOf("docker", "container", "rm", containerId))
}

fun removeTitanImages(version: String): String {
val imageId = executor.exec(listOf("docker", "images", "titan:$version", "--format", "{{.ID}}")).trim()
return executor.exec(listOf("docker", "rmi", imageId, "-f"))
}

fun run(image: String, entry: String, arguments: List<String>): String {
val mutArgs = mutableListOf("docker", "run")
mutArgs.addAll(arguments)
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/io/titandata/titan/providers/Local.kt
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class Local: Provider {
}

override fun uninstall(force: Boolean) {
val uninstallCommand = Uninstall(::exit, ::remove, commandExecutor, docker)
val uninstallCommand = Uninstall(titanServerVersion, ::exit, ::remove, commandExecutor, docker)
return uninstallCommand.uninstall(force)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import io.titandata.titan.exceptions.CommandException
import io.titandata.titan.utils.CommandExecutor

class Uninstall (
private val titanServerVersion: String,
private val exit: (message: String, code: Int) -> Unit,
private val remove: (container: String, force: Boolean) -> Unit,
private val commandExecutor: CommandExecutor = CommandExecutor(),
Expand All @@ -35,6 +36,7 @@ class Uninstall (
try {
docker.removeVolume("titan-data")
} catch (e: CommandException) {}
docker.removeTitanImages(titanServerVersion)
println("Uninstalled titan infrastructure")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import org.junit.Test
class UninstallTest {
private fun exit(message: String, code: Int) {}
private fun remove(container: String, force: Boolean) {}
private val command = Uninstall(::exit, ::remove)
private val command = Uninstall("version", ::exit, ::remove)

@Test
fun `can instantiate`(){
Expand Down

0 comments on commit 768b587

Please sign in to comment.