Skip to content
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

Windows and various issues #52

Merged
merged 30 commits into from
Oct 3, 2019
Merged
Show file tree
Hide file tree
Changes from 29 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
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
if: matrix.os == 'ubuntu-18.04'
uses: actions/upload-artifact@master
with:
name: titan-cli-0.3.0-linux_amd64.zip
mcred marked this conversation as resolved.
Show resolved Hide resolved
name: titan-cli-0.3.0-linux_amd64.tar
path: releases
release:
name: Draft Release
Expand All @@ -45,7 +45,7 @@ jobs:
path: releases
- uses: actions/download-artifact@master
with:
name: titan-cli-0.3.0-linux_amd64.zip
name: titan-cli-0.3.0-linux_amd64.tar
path: releases
- name: Draft Release
if: startsWith(github.ref, 'refs/tags/')
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Titan
## Your Code. Your Environment. Your Data.

![](https://github.com/titan-data/titan/workflows/Publish/badge.svg)
![GitHub release (latest by date)](https://img.shields.io/github/v/release/titan-data/titan)
![GitHub All Releases](https://img.shields.io/github/downloads/titan-data/titan/total)

## <a id="getting-started"></a> Getting Started

### <a id="requirements"></a> Requirements
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.3.1
0.3.2
9 changes: 9 additions & 0 deletions config/jni-config.json
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
[
{
"name":"java.net.SocketTimeoutException",
"allDeclaredFields":true,
"allPublicMethods":true,
"allDeclaredConstructors":true,
"allPublicConstructors":true,
"allDeclaredClasses":true,
"allPublicClasses":true
}
]
1 change: 1 addition & 0 deletions docs/src/cli/cli.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Subcommands
cmd/checkout
cmd/clone
cmd/commit
cmd/delete
cmd/cp
cmd/install
cmd/log
Expand Down
8 changes: 7 additions & 1 deletion docs/src/cli/cmd/clone.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Syntax

::

titan clone <uri> [repository]
mcred marked this conversation as resolved.
Show resolved Hide resolved
titan clone -c [id] <uri> [repository]

Arguments
---------
Expand All @@ -29,6 +29,12 @@ repository
the name of the original repository is used (which may or may not match
the name used in the remote URI).

Options
-------

-c, --commit id Specify the commit ID to checkout.


Example
-------

Expand Down
41 changes: 41 additions & 0 deletions docs/src/cli/cmd/delete.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
.. _cli_cmd_delete:

titan delete
==============

Delete a previous commit from the current container. The commit must be
present in `titan log`. For more general information on managing local
commits, see the :ref:`local_commit` section.

.. warning::

This will stop and start the associated docker container if it is already
running. This will interrupt any active connections, and may require
client-specific actions to reconnect.

Syntax
------

::

titan delete -c <id> <repository>

Arguments
---------

repository
*Required*. The name of the target repository.

Options
-------

-c, --commit id *Required*. Specify the commit ID to delete. Must be a known
commit in `titan log` for the given repository.

Example
-------

::

$ titan checkout -c 7715327e-9535-4263-870f-f5c92c18cb23 myrepo
7715327e-9535-4263-870f-f5c92c18cb23 deleted
mcred marked this conversation as resolved.
Show resolved Hide resolved
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<artifactId>titan</artifactId>
<name>Titan CLI</name>
<description></description>
<version>0.3.1</version>
<version>0.3.2</version>

<properties>
<java.version>1.8</java.version>
Expand Down Expand Up @@ -123,7 +123,7 @@
<dependency>
<groupId>io.titandata</groupId>
<artifactId>titan-client</artifactId>
<version>0.4.1</version>
<version>0.4.4</version>
</dependency>
</dependencies>

Expand Down
5 changes: 3 additions & 2 deletions scripts/build-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ ${entry} native-image -cp /cli/target/titan-$version-jar-with-dependencies.jar\
-H:+ReportUnsupportedElementsAtRuntime\
-H:ReflectionConfigurationFiles=/cli/config/reflect-config.json\
-H:ResourceConfigurationFiles=/cli/config/resource-config.json\
-H:JNIConfigurationFiles=/cli/config/jni-config.json\
-H:+AddAllCharsets\
--initialize-at-run-time=org.bouncycastle.crypto.prng.SP800SecureRandom\
--initialize-at-run-time=org.bouncycastle.jcajce.provider.drbg.DRBG$Default\
--initialize-at-run-time=org.bouncycastle.jcajce.provider.drbg.DRBG$NonceAndIV\
-J-Djava.security.properties=${PWD}/java.security.overrides\
-J-Djava.security.properties=/cli/java.security.overrides\
--allow-incomplete-classpath\
--enable-http\
--enable-https

${entry} mkdir -p /cli/releases/
${entry} tar -cvf /cli/releases/titan-cli-$version-linux_amd64.zip titan
${entry} tar -cvf /cli/releases/titan-cli-$version-linux_amd64.tar titan
1 change: 1 addition & 0 deletions scripts/build-osx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ native-image -cp ${PWD}/target/titan-$version-jar-with-dependencies.jar\
-H:+ReportUnsupportedElementsAtRuntime\
-H:ReflectionConfigurationFiles=${PWD}/config/reflect-config.json\
-H:ResourceConfigurationFiles=${PWD}/config/resource-config.json\
-H:JNIConfigurationFiles=${PWD}/config/jni-config.json\
-H:+AddAllCharsets\
--initialize-at-run-time=org.bouncycastle.crypto.prng.SP800SecureRandom\
--initialize-at-run-time=org.bouncycastle.jcajce.provider.drbg.DRBG$Default\
Expand Down
1 change: 1 addition & 0 deletions src/main/kotlin/io/titandata/titan/Cli.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ object Cli {
import(startModule)
import(stopModule)
import(commitModule)
import(deleteModule)
import(checkoutModule)
import(listModule)
import(logModule)
Expand Down
5 changes: 4 additions & 1 deletion src/main/kotlin/io/titandata/titan/commands/Clone.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import com.github.ajalt.clikt.core.CliktCommand
import com.github.ajalt.clikt.core.requireObject
import com.github.ajalt.clikt.parameters.arguments.argument
import com.github.ajalt.clikt.parameters.arguments.optional
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
Expand All @@ -18,9 +19,11 @@ class Clone : CliktCommand(help = "Clone a remote repository to local repository
private val dependencies: Dependencies by requireObject()
private val uri by argument()
private val repository by argument().optional()
private val commit by option("-c", "--commit", help="Commit GUID to pull from, defaults to latest")

override fun run() {
val provider = dependencies.provider
provider.clone(uri, repository)
provider.clone(uri, repository, commit)
}
}

Expand Down
33 changes: 33 additions & 0 deletions src/main/kotlin/io/titandata/titan/commands/Delete.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright (c) 2019 by Delphix. All rights reserved.
*/

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.arguments.argument
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 Delete : CliktCommand(
help = "Delete objects from titan"
) {
private val dependencies: Dependencies by requireObject()
private val repository by argument()
private val commit by option("-c", "--commit", help="Commit GUID to delete")
override fun run() {
val provider = dependencies.provider
provider.delete(repository, commit)
}
}

val deleteModule = Kodein.Module("delete") {
bind<CliktCommand>().inSet() with provider {
Delete()
}
}
14 changes: 11 additions & 3 deletions src/main/kotlin/io/titandata/titan/providers/Local.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ data class Container (
)

class Local: Provider {
private val titanServerVersion = "0.4.1"
private val titanServerVersion = "0.4.4"
private val dockerRegistryUrl = "titandata"

private val httpHandler = HttpHandler()
Expand Down Expand Up @@ -171,9 +171,17 @@ class Local: Provider {
return cpCommand.cp(container, driver, source, path)
}

override fun clone(uri: String, container: String?) {
override fun clone(uri: String, container: String?, commit: String?) {
val runCommand = Run(::exit, commandExecutor, docker)
val cloneCommand = Clone(::remoteAdd, ::pull, ::checkout, runCommand::run, ::remove, commandExecutor, docker)
return cloneCommand.clone(uri, container)
return cloneCommand.clone(uri, container, commit)
}

override fun delete(repository: String, commit: String?) {
val deleteCommand = Delete()
if (!commit.isNullOrEmpty()) {
return deleteCommand.deleteCommit(repository, commit)
}
println("No object found to delete.")
}
}
6 changes: 5 additions & 1 deletion src/main/kotlin/io/titandata/titan/providers/Mock.kt
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,11 @@ class Mock: Provider {
println("copying data into $container with $driver from $source")
}

override fun clone(uri: String, container: String?) {
override fun clone(uri: String, container: String?, commit: String?) {
println("cloning $container from $uri")
}

override fun delete(repository: String, commit: String?) {
println("deleting $commit from $repository")
}
}
3 changes: 2 additions & 1 deletion src/main/kotlin/io/titandata/titan/providers/Provider.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ interface Provider {
fun uninstall(force: Boolean)
fun upgrade(force: Boolean, version: String, finalize: Boolean, path: String?)
fun checkout(container: String, guid: String)
fun delete(repository: String, commit: String?)
fun list()
fun log(container: String)
fun stop(container: String)
fun start(container: String)
fun remove(container: String, force: Boolean)
fun cp(container: String, driver: String, source: String, path: String)
fun clone(uri: String, container: String?)
fun clone(uri: String, container: String?, commit: String?)
}
24 changes: 18 additions & 6 deletions src/main/kotlin/io/titandata/titan/providers/local/Clone.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ package io.titandata.titan.providers.local

import io.titandata.client.apis.RemotesApi
import io.titandata.client.apis.RepositoriesApi
import io.titandata.models.Commit
import io.titandata.titan.clients.Docker
import io.titandata.titan.clients.Docker.Companion.runtimeToArguments
import io.titandata.models.Repository
import io.titandata.titan.utils.CommandExecutor
import io.titandata.serialization.RemoteUtil
import io.titandata.titan.exceptions.CommandException

class Clone (
private val remoteAdd: (container:String, uri: String, remoteName: String?) -> Unit,
Expand All @@ -24,18 +26,27 @@ class Clone (
private val repositoriesApi: RepositoriesApi = RepositoriesApi(),
private val remoteUtil: RemoteUtil = RemoteUtil()
) {
fun clone(uri: String, container: String?) {
fun clone(uri: String, container: String?, guid: String?) {
val repoName = when(container){
null -> uri.split("/").last()
null -> uri.split("/").last().substringBefore('#')
else -> container
}
val commitId = when {
guid.isNullOrEmpty() && uri.contains('#') -> uri.split("#").last()
else -> guid
}
val repository = Repository(repoName, emptyMap())
try {
repositoriesApi.createRepository(repository)
remoteAdd(repoName, uri, null)
remoteAdd(repoName, uri.substringBefore('#'), null)
val remote = remotesApi.getRemote(repoName, "origin")
val remoteCommits = remotesApi.listRemoteCommits(repoName, remote.name, remoteUtil.getParameters(remote))
val commit = remoteCommits.first()
var commit = Commit("id", emptyMap())
if (commitId.isNullOrEmpty()) {
val remoteCommits = remotesApi.listRemoteCommits(repoName, remote.name, remoteUtil.getParameters(remote))
commit = remoteCommits.first()
} else {
commit = remotesApi.getRemoteCommit(repoName, remote.name, commitId, remoteUtil.getParameters(remote))
}
docker.pull(commit.properties["container"] as String)
val runtime = commit.properties["runtime"] as String
val arguments = runtime.runtimeToArguments().toMutableList()
Expand All @@ -44,9 +55,10 @@ class Clone (
run(arguments, false)
pull(repoName, commit.id, null)
checkout(repoName, commit.id)
} catch (e: Throwable) {
} catch (e: CommandException) {
println("Clone failed.")
println(e.message)
println(e.output)
remove(repository.name, true)
}
}
Expand Down
16 changes: 16 additions & 0 deletions src/main/kotlin/io/titandata/titan/providers/local/Delete.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Copyright (c) 2019 by Delphix. All rights reserved.
*/

package io.titandata.titan.providers.local

import io.titandata.client.apis.CommitsApi

class Delete (
private val commitsApi: CommitsApi = CommitsApi()
) {
fun deleteCommit(repository: String, commit: String) {
commitsApi.deleteCommit(repository, commit)
println("$commit deleted")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ class Pull (
val statuses = operationsApi.getProgress(container, operation.id)
for (status in statuses) {
if (status.type != ProgressEntry.Type.PROGRESS) {
println(status.message)
if (!status.message.isNullOrEmpty()) {
println(status.message)
}
} else {
val subMessage = status.message as String
if (subMessage.length > padLen) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ class Push (
val statuses = operationsApi.getProgress(container, operation.id)
for (status in statuses) {
if (status.type != ProgressEntry.Type.PROGRESS) {
println(status.message)
if (!status.message.isNullOrEmpty()) {
println(status.message)
}
} else {
val subMessage = status.message as String
if (subMessage.length > padLen) {
Expand Down
Loading