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

Commit

Permalink
fixes #8
Browse files Browse the repository at this point in the history
Signed-off-by: Derek Smart <[email protected]>
  • Loading branch information
Derek Smart committed Sep 26, 2019
1 parent 4686be9 commit 94a948b
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 6 deletions.
4 changes: 3 additions & 1 deletion src/main/kotlin/io/titandata/titan/commands/Install.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,18 @@ package io.titandata.titan.commands
import io.titandata.titan.Dependencies
import com.github.ajalt.clikt.core.CliktCommand
import com.github.ajalt.clikt.core.requireObject
import com.github.ajalt.clikt.parameters.options.option
import org.kodein.di.Kodein
import org.kodein.di.generic.bind
import org.kodein.di.generic.inSet
import org.kodein.di.generic.provider

class Install : CliktCommand(help = "Install titan infrastructure") {
private val dependencies: Dependencies by requireObject()
private val registry by option("-r","--registry", help = "Registry URL for titan docker image, defaults to titandata")
override fun run() {
val provider = dependencies.provider
provider.install()
provider.install(registry)
}
}

Expand Down
9 changes: 7 additions & 2 deletions src/main/kotlin/io/titandata/titan/providers/Local.kt
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,13 @@ class Local: Provider {
return checkInstallCommand.checkInstall()
}

override fun install() {
val installCommand = Install(titanServerVersion, dockerRegistryUrl, commandExecutor, docker)
override fun install(registry: String?) {
val regVal = if (registry.isNullOrEmpty()) {
dockerRegistryUrl
} else {
registry
}
val installCommand = Install(titanServerVersion, regVal, commandExecutor, docker)
return installCommand.install()
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/io/titandata/titan/providers/Mock.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Mock: Provider {
println("Committing new state")
}

override fun install() {
override fun install(registry: String?) {
println("Initializing new repository")
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/io/titandata/titan/providers/Provider.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ interface Provider {
fun pull(container: String, commit: String?, remoteName: String?)
fun push(container: String, commit: String?, remoteName: String?)
fun commit(container: String, message: String)
fun install()
fun install(registry: String?)
fun abort(container: String)
fun status(container: String)
fun remoteAdd(container: String, uri: String, remoteName: String?)
Expand Down
2 changes: 1 addition & 1 deletion src/test/kotlin/io/titandata/titan/providers/MockTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class MockTest {
fun `can install`(){
val byteStream = ByteArrayOutputStream()
System.setOut(PrintStream(byteStream))
mockProvider.install()
mockProvider.install("registry")
byteStream.flush()
val expected = String(byteStream.toByteArray()).trim()
assertEquals(expected, "Initializing new repository")
Expand Down

0 comments on commit 94a948b

Please sign in to comment.