Skip to content

Commit

Permalink
implement clone (#120)
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Schrock authored and Derek Smart committed Dec 2, 2019
1 parent 46587f3 commit b1ddbc2
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 10 deletions.
14 changes: 12 additions & 2 deletions src/main/kotlin/io/titandata/titan/clients/Docker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,18 @@ class Docker(private val executor: CommandExecutor, val identity: String = "tita
return run("titan:latest", "/bin/bash /titan/teardown", titanLaunchArgs)
}

fun launchTitanKubernetesServers(): String {
return run("titan:latest", "/bin/bash /titan/run", titanLaunchKubernetesArgs)
fun launchTitanKubernetesServers(titanServerVersion: String): String {
var config = System.getenv("TITAN_CONFIG") ?: ""
if (!config.contains("titanImage")) {
if (config != "") {
config += ","
}
config += "titanImage=titandata/titan:$titanServerVersion"
}
val launchArgs = titanLaunchKubernetesArgs.toMutableList()
launchArgs.add("-e")
launchArgs.add("TITAN_CONFIG=$config")
return run("titan:latest", "/bin/bash /titan/run", launchArgs)
}

fun pull(image: String): String {
Expand Down
8 changes: 6 additions & 2 deletions src/main/kotlin/io/titandata/titan/providers/Kubernetes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import io.titandata.serialization.RemoteUtil
import io.titandata.titan.clients.Docker
import io.titandata.titan.exceptions.CommandException
import io.titandata.titan.providers.generic.Abort
import io.titandata.titan.providers.generic.Clone
import io.titandata.titan.providers.generic.Commit
import io.titandata.titan.providers.generic.Delete
import io.titandata.titan.providers.generic.Log
Expand Down Expand Up @@ -221,10 +222,13 @@ class Kubernetes : Provider {
}

override fun cp(container: String, driver: String, source: String, path: String) {
throw NotImplementedError("cp is not supported in kuberentes context")
throw NotImplementedError("cp is not supported in kubernetes context")
}

override fun clone(uri: String, container: String?, commit: String?, params: Map<String, String>, arguments: List<String>, disablePortMapping: Boolean) {
TODO("not implemented")
val runCommand = Run(::exit, commandExecutor, docker, kubernetes, repositoriesApi, volumesApi)
val cloneCommand = Clone(::remoteAdd, ::pull, ::checkout, runCommand::run, ::remove, commandExecutor, docker,
remotesApi, repositoriesApi)
return cloneCommand.clone(uri, container, commit, params, arguments, disablePortMapping)
}
}
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 @@ -8,6 +8,7 @@ import io.titandata.client.apis.RepositoriesApi
import io.titandata.titan.clients.Docker
import io.titandata.titan.exceptions.CommandException
import io.titandata.titan.providers.generic.Abort
import io.titandata.titan.providers.generic.Clone
import io.titandata.titan.providers.generic.Commit
import io.titandata.titan.providers.generic.Delete
import io.titandata.titan.providers.generic.Log
Expand All @@ -23,7 +24,6 @@ import io.titandata.titan.providers.generic.Tag
import io.titandata.titan.providers.generic.Upgrade
import io.titandata.titan.providers.local.CheckInstall
import io.titandata.titan.providers.local.Checkout
import io.titandata.titan.providers.local.Clone
import io.titandata.titan.providers.local.Cp
import io.titandata.titan.providers.local.Install
import io.titandata.titan.providers.local.Migrate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Copyright (c) 2019 by Delphix. All rights reserved.
*/

package io.titandata.titan.providers.local
package io.titandata.titan.providers.generic

import io.titandata.client.apis.RemotesApi
import io.titandata.client.apis.RepositoriesApi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class Pull(
}
var operation = operationsApi.pull(container, remote.name, commit.id, remoteUtil.getParameters(remote),
metadataOnly)
if (!OperationMonitor(container, operation).monitor()) {
if (!OperationMonitor(container, operation, operationsApi).monitor()) {
exit("", 1)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class Push(
val remote = remotesApi.getRemote(container, name)
var operation = operationsApi.push(container, remote.name, commit, remoteUtil.getParameters(remote),
metadataOnly)
if (!OperationMonitor(container, operation).monitor()) {
if (!OperationMonitor(container, operation, operationsApi).monitor()) {
exit("", 1)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Install(
}
}
track("Starting titan server docker containers") {
docker.launchTitanKubernetesServers()
docker.launchTitanKubernetesServers(titanServerVersion)
}

println("Titan cli successfully installed, happy data versioning :)")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.titandata.titan.providers.local
package io.titandata.titan.providers.generic

import org.hamcrest.CoreMatchers.instanceOf
import org.junit.Assert.assertThat
Expand Down

0 comments on commit b1ddbc2

Please sign in to comment.