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

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update from fork #32

Merged
merged 2 commits into from
Nov 26, 2019
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
3 changes: 3 additions & 0 deletions .github/workflows/end-to-end-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,8 @@ jobs:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
- name: Build Nginx Docker Container
working-directory: ./src/endtoend-test/context/docker
run: docker build -t nginx-test .
- name: Run Docker Context Tests
run: java -jar vexrun.jar -d ./src/endtoend-test/context/docker
2 changes: 0 additions & 2 deletions src/endtoend-test/context/docker/DockerTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ tests:
- "can install titan":
command: titan install
wait: 10
- "can build nginx-test":
command: cd src/endtoend-test/context/docker && docker build -t nginx-test -f ./src/endtoend-test/context/docker/Dockerfile .
- "can run nginx-test":
command: titan run nginx-test
- "can remove nginx-test":
Expand Down
4 changes: 2 additions & 2 deletions src/endtoend-test/getting-started/GettingStartedTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ tests:
wait: 10
stdout:
contains: Titan cli successfully installed, happy data versioning :)
- "can clone hello-world/posrgres":
- "can clone hello-world/postgres":
command: titan clone -n hello-world s3web://demo.titan-data.io/hello-world/postgres
stdout:
contains:
Expand Down Expand Up @@ -85,4 +85,4 @@ tests:
stdout:
contains: Uninstalled titan infrastructure
after:
clearVars: true
clearVars: true
4 changes: 2 additions & 2 deletions src/endtoend-test/remotes/s3/s3WorkflowTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ tests:
wait: 30
stdout:
contains: Titan cli successfully installed, happy data versioning :)
- "can clone hello-world/posrgres":
- "can clone hello-world/postgres":
command: titan clone -n hello-world s3web://demo.titan-data.io/hello-world/postgres
stdout:
contains:
Expand All @@ -37,4 +37,4 @@ files:
URI: s3://titan-data-testdata/e2etest
REPO: hello-world
after:
clearVars: true
clearVars: true
8 changes: 1 addition & 7 deletions src/main/kotlin/io/titandata/titan/Cli.kt
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,7 @@ object Cli {
class Titan : CliktCommand(help = "Titan CLI") {

override fun run() {
val providerFactory = ProviderFactory()
val type = System.getenv("TITAN_CONTEXT") ?: "local"
val provider = providerFactory.getFactory(type)
context.obj = Dependencies(provider)
if (context.invokedSubcommand?.commandName != "install") {
provider.checkInstall()
}
context.obj = Dependencies(ProviderFactory())
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/io/titandata/titan/Dependencies.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package io.titandata.titan

import io.titandata.titan.providers.Provider
import io.titandata.titan.providers.ProviderFactory

data class Dependencies(val provider: Provider)
data class Dependencies(val providers: ProviderFactory)
2 changes: 1 addition & 1 deletion src/main/kotlin/io/titandata/titan/commands/Abort.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Abort : CliktCommand(help = "Abort current push or pull operation") {
private val dependencies: Dependencies by requireObject()
private val repository: String by argument()
override fun run() {
val provider = dependencies.provider
val provider = dependencies.providers.byRepository(repository)
provider.abort(repository)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/io/titandata/titan/commands/Checkout.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Checkout : CliktCommand(help = "Checkout a specific commit") {
private val commit by option("-c", "--commit", help = "Commit to checkout")
private val tags by option("-t", "--tag", help = "Tag to filter latest commit, if commit is not specified").multiple()
override fun run() {
val provider = dependencies.provider
val provider = dependencies.providers.byRepository(repository)
provider.checkout(repository, commit, tags)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/io/titandata/titan/commands/Clone.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Clone : CliktCommand(help = "Clone a remote repository to local repository
private val arguments by argument().multiple()

override fun run() {
val provider = dependencies.provider
val provider = dependencies.providers.byRepositoryName(repository)
val params = mutableMapOf<String, String>()
for (param in parameters) {
val split = param.split("=")
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/io/titandata/titan/commands/Commit.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Commit : CliktCommand(help = "Commit current data state") {
private val message by option("-m", "--message", help = "Commit message").default("")
private val tags by option("-t", "--tag", help = "Tag to set").multiple()
override fun run() {
val provider = dependencies.provider
val provider = dependencies.providers.byRepository(repository)
provider.commit(repository, message, tags)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/io/titandata/titan/commands/Cp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Cp : CliktCommand(
private val source by option("-s", "--source", help = "Required. Source location of the files on the local machine").required()
private val destination by option("-d", "--destination", help = "Destination of the files inside of the container").default("")
override fun run() {
val provider = dependencies.provider
val provider = dependencies.providers.byRepository(repository)
provider.cp(repository, "local", source, destination)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/io/titandata/titan/commands/Delete.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class Delete : CliktCommand(
private val commit by option("-c", "--commit", help = "Commit GUID to delete")
private val tags by option("-t", "--tag", help = "Tags to remove from a commit").multiple()
override fun run() {
val provider = dependencies.provider
val provider = dependencies.providers.byRepository(repository)
provider.delete(repository, commit, tags)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/io/titandata/titan/commands/Install.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class Install : CliktCommand(help = "Install titan infrastructure") {
private val registry by option("-r", "--registry", help = "Registry URL for titan docker image, defaults to titandata")
private val verbose by option("-V", "--verbose", help = "Verbose output of Titan Server installation steps.").flag(default = false)
override fun run() {
val provider = dependencies.provider
val provider = dependencies.providers.default(false)
provider.install(registry, verbose)
}
}
Expand Down
10 changes: 8 additions & 2 deletions src/main/kotlin/io/titandata/titan/commands/List.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,15 @@ import org.kodein.di.generic.provider

class List : CliktCommand(help = "List repositories", name = "ls") {
private val dependencies: Dependencies by requireObject()
private val n = System.lineSeparator()

override fun run() {
val provider = dependencies.provider
provider.list()
// Check that we have at least one context installed
dependencies.providers.default()
System.out.printf("%-20s %s$n", "REPOSITORY", "STATUS")
for (provider in dependencies.providers.list()) {
provider.list()
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/io/titandata/titan/commands/Log.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Log : CliktCommand(help = "List commits for a repository") {
private val repository by argument()
private val tags by option("-t", "--tag", help = "Tag to set").multiple()
override fun run() {
val provider = dependencies.provider
val provider = dependencies.providers.byRepository(repository)
provider.log(repository, tags)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/io/titandata/titan/commands/Migrate.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Migrate : CliktCommand(
private val repository by argument()
private val source by option("-s", "--source", help = "Required. Source docker database container").required()
override fun run() {
val provider = dependencies.provider
val provider = dependencies.providers.default()
provider.migrate(source, repository)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/io/titandata/titan/commands/Pull.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Pull : CliktCommand(help = "Pull a new data state from remote") {
private val repository by argument()

override fun run() {
val provider = dependencies.provider
val provider = dependencies.providers.byRepository(repository)
provider.pull(repository, commit, remote, tags, metadataOnly)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/io/titandata/titan/commands/Push.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Push : CliktCommand(help = "Push data state to remote") {
private val repository: String by argument()

override fun run() {
val provider = dependencies.provider
val provider = dependencies.providers.byRepository(repository)
provider.push(repository, commit, remote, tags, metadataOnly)
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/main/kotlin/io/titandata/titan/commands/Remote.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class RemoteAdd : CliktCommand(help = "Set remote destination for a repository",
private val repository: String by argument()

override fun run() {
val provider = dependencies.provider
val provider = dependencies.providers.byRepository(repository)
val params = mutableMapOf<String, String>()
for (param in parameters) {
val split = param.split("=")
Expand All @@ -49,7 +49,7 @@ class RemoteLog : CliktCommand(help = "Display log on remote", name = "log") {
private val tags by option("-t", "--tag", help = "Tag to set").multiple()

override fun run() {
val provider = dependencies.provider
val provider = dependencies.providers.byRepository(repository)
provider.remoteLog(repository, remote, tags)
}
}
Expand All @@ -59,7 +59,7 @@ class RemoteList : CliktCommand(help = "List remotes for a repository", name = "
private val repository: String by argument()

override fun run() {
val provider = dependencies.provider
val provider = dependencies.providers.byRepository(repository)
provider.remoteList(repository)
}
}
Expand All @@ -70,7 +70,7 @@ class RemoteRemove : CliktCommand(help = "Remove remote from a repository", name
private val remote: String by argument()

override fun run() {
val provider = dependencies.provider
val provider = dependencies.providers.byRepository(repository)
provider.remoteRemove(repository, remote)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/io/titandata/titan/commands/Remove.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Remove : CliktCommand(help = "Remove a repository", name = "rm") {
private val dependencies: Dependencies by requireObject()
private val repository by argument()
override fun run() {
val provider = dependencies.provider
val provider = dependencies.providers.byRepository(repository)
provider.remove(repository, force)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/io/titandata/titan/commands/Run.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Run : CliktCommand(
private val repository by option("-n", "--name", help = "Optional new name for repository.")
private val arguments by argument().multiple()
override fun run() {
val provider = dependencies.provider
val provider = dependencies.providers.byRepositoryName(repository)
provider.run(image, repository, environments, arguments, disablePortMapping)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/io/titandata/titan/commands/Start.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Start : CliktCommand(help = "Start a container for a repository") {
private val dependencies: Dependencies by requireObject()
private val repository by argument()
override fun run() {
val provider = dependencies.provider
val provider = dependencies.providers.byRepository(repository)
provider.start(repository)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/io/titandata/titan/commands/Status.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Status : CliktCommand(help = "Display current status for a repository") {
private val repository: String by argument()

override fun run() {
val provider = dependencies.provider
val provider = dependencies.providers.byRepository(repository)
provider.status(repository)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/io/titandata/titan/commands/Stop.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Stop : CliktCommand(help = "Stop a running container for a repository") {
private val dependencies: Dependencies by requireObject()
private val repository by argument()
override fun run() {
val provider = dependencies.provider
val provider = dependencies.providers.byRepository(repository)
provider.stop(repository)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/io/titandata/titan/commands/Tag.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Tag : CliktCommand(
private val commit by option("-c", "--commit", help = "Commit GUID to tag").required()
private val tags by option("-t", "--tag", help = "Tags to add").multiple()
override fun run() {
val provider = dependencies.provider
val provider = dependencies.providers.byRepository(repository)
provider.tag(repository, commit, tags)
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/main/kotlin/io/titandata/titan/commands/Uninstall.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ class Uninstall : CliktCommand(help = "Uninstall titan infrastructure") {
private val force by option("-f", "--force", help = "Destroy all repositories").flag(default = false)
private val dependencies: Dependencies by requireObject()
override fun run() {
val provider = dependencies.provider
provider.uninstall(force)
for (provider in dependencies.providers.list()) {
provider.uninstall(force)
}
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/main/kotlin/io/titandata/titan/commands/Upgrade.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ class Upgrade : CliktCommand(help = "Upgrade titan CLI and infrastructure") {
private val finalize by option("--finalize").flag(default = false)
private val path by option("-p", "--path", help = "Full installation path of Titan").default("")
override fun run() {
val provider = dependencies.provider
// TODO This command is not really provider-specific
val provider = dependencies.providers.default()

provider.upgrade(force, version, finalize, path)
}
Expand Down
1 change: 0 additions & 1 deletion src/main/kotlin/io/titandata/titan/providers/Kubernetes.kt
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ class Kubernetes : Provider {
}

override fun list() {
System.out.printf("%-20s %s$n", "REPOSITORY", "STATUS")
for (container in getRuntimeStatus()) {
System.out.printf("%-20s %s$n", container.name, container.status)
}
Expand Down
1 change: 0 additions & 1 deletion src/main/kotlin/io/titandata/titan/providers/Local.kt
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ class Local : Provider {
}

override fun list() {
System.out.printf("%-20s %s$n", "REPOSITORY", "STATUS")
for (container in getContainersStatus()) {
System.out.printf("%-20s %s$n", container.name, container.status)
}
Expand Down
31 changes: 29 additions & 2 deletions src/main/kotlin/io/titandata/titan/providers/ProviderFactory.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,38 @@
package io.titandata.titan.providers

class ProviderFactory {
fun getFactory(name: String): Provider {
return when (name) {

private val provider: Provider

init {
val type = System.getenv("TITAN_CONTEXT") ?: "local"
provider = when (type) {
"local" -> Local()
"kubernetes" -> Kubernetes()
else -> Mock()
}
}

fun list(): List<Provider> {
return listOf(provider)
}

fun byRepositoryName(repoName: String?): Provider {
if (repoName == null) {
return default()
} else {
return provider
}
}

fun byRepository(repoName: String): Provider {
return provider
}

fun default(checkInstall: Boolean = true): Provider {
if (checkInstall) {
provider.checkInstall()
}
return provider
}
}
17 changes: 0 additions & 17 deletions src/test/kotlin/io/titandata/titan/DependenciesTest.kt

This file was deleted.

Loading