diff --git a/VERSION b/VERSION
index 9fc80f93..87a08711 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.3.2
\ No newline at end of file
+0.3.3
\ No newline at end of file
diff --git a/config/reflect-config.json b/config/reflect-config.json
index 08f93d7a..096b7279 100644
--- a/config/reflect-config.json
+++ b/config/reflect-config.json
@@ -18,7 +18,7 @@
"allPublicClasses":true
},
{
- "name":"io.titandata.models.EngineParameters",
+ "name":"io.titandata.remote.engine.EngineParameters",
"allDeclaredFields":true,
"allPublicMethods":true,
"allDeclaredConstructors":true,
@@ -27,7 +27,7 @@
"allPublicClasses":true
},
{
- "name":"io.titandata.models.EngineParameters[]",
+ "name":"io.titandata.remote.engine.EngineParameters[]",
"allDeclaredFields":true,
"allPublicMethods":true,
"allDeclaredConstructors":true,
@@ -36,7 +36,7 @@
"allPublicClasses":true
},
{
- "name":"io.titandata.models.EngineRemote",
+ "name":"io.titandata.remote.engine.EngineRemote",
"allDeclaredFields":true,
"allPublicMethods":true,
"allDeclaredConstructors":true,
@@ -45,7 +45,7 @@
"allPublicClasses":true
},
{
- "name":"io.titandata.models.EngineRemote[]",
+ "name":"io.titandata.remote.engine.EngineRemote[]",
"allDeclaredFields":true,
"allPublicMethods":true,
"allDeclaredConstructors":true,
@@ -72,7 +72,7 @@
"allPublicClasses":true
},
{
- "name":"io.titandata.models.NopParameters",
+ "name":"io.titandata.remote.nop.NopParameters",
"allDeclaredFields":true,
"allPublicMethods":true,
"allDeclaredConstructors":true,
@@ -81,7 +81,7 @@
"allPublicClasses":true
},
{
- "name":"io.titandata.models.NopParameters[]",
+ "name":"io.titandata.remote.nop.NopParameters[]",
"allDeclaredFields":true,
"allPublicMethods":true,
"allDeclaredConstructors":true,
@@ -90,7 +90,7 @@
"allPublicClasses":true
},
{
- "name":"io.titandata.models.NopRemote",
+ "name":"io.titandata.remote.nop.NopRemote",
"allDeclaredFields":true,
"allPublicMethods":true,
"allDeclaredConstructors":true,
@@ -99,7 +99,7 @@
"allPublicClasses":true
},
{
- "name":"io.titandata.models.NopRemote[]",
+ "name":"io.titandata.remote.nop.NopRemote[]",
"allDeclaredFields":true,
"allPublicMethods":true,
"allDeclaredConstructors":true,
@@ -245,7 +245,7 @@
"allPublicClasses":true
},
{
- "name":"io.titandata.models.S3Parameters",
+ "name":"io.titandata.remote.s3.S3Parameters",
"allDeclaredFields":true,
"allPublicMethods":true,
"allDeclaredConstructors":true,
@@ -254,7 +254,7 @@
"allPublicClasses":true
},
{
- "name":"io.titandata.models.S3Parameters[]",
+ "name":"io.titandata.remote.s3.S3Parameters[]",
"allDeclaredFields":true,
"allPublicMethods":true,
"allDeclaredConstructors":true,
@@ -263,7 +263,7 @@
"allPublicClasses":true
},
{
- "name":"io.titandata.models.S3Remote",
+ "name":"io.titandata.remote.s3.S3Remote",
"allDeclaredFields":true,
"allPublicMethods":true,
"allDeclaredConstructors":true,
@@ -272,7 +272,7 @@
"allPublicClasses":true
},
{
- "name":"io.titandata.models.S3Remote[]",
+ "name":"io.titandata.remote.s3.S3Remote[]",
"allDeclaredFields":true,
"allPublicMethods":true,
"allDeclaredConstructors":true,
@@ -281,7 +281,7 @@
"allPublicClasses":true
},
{
- "name":"io.titandata.models.SshParameters",
+ "name":"io.titandata.remote.s3web.S3WebParameters",
"allDeclaredFields":true,
"allPublicMethods":true,
"allDeclaredConstructors":true,
@@ -290,7 +290,7 @@
"allPublicClasses":true
},
{
- "name":"io.titandata.models.SshParameters[]",
+ "name":"io.titandata.remote.s3web.S3WebParameters[]",
"allDeclaredFields":true,
"allPublicMethods":true,
"allDeclaredConstructors":true,
@@ -299,7 +299,7 @@
"allPublicClasses":true
},
{
- "name":"io.titandata.models.SshRemote",
+ "name":"io.titandata.remote.s3web.S3WebRemote",
"allDeclaredFields":true,
"allPublicMethods":true,
"allDeclaredConstructors":true,
@@ -308,7 +308,43 @@
"allPublicClasses":true
},
{
- "name":"io.titandata.models.SshRemote[]",
+ "name":"io.titandata.remote.s3web.S3WebRemote[]",
+ "allDeclaredFields":true,
+ "allPublicMethods":true,
+ "allDeclaredConstructors":true,
+ "allPublicConstructors":true,
+ "allDeclaredClasses":true,
+ "allPublicClasses":true
+},
+{
+ "name":"io.titandata.remote.ssh.SshParameters",
+ "allDeclaredFields":true,
+ "allPublicMethods":true,
+ "allDeclaredConstructors":true,
+ "allPublicConstructors":true,
+ "allDeclaredClasses":true,
+ "allPublicClasses":true
+},
+{
+ "name":"io.titandata.remote.ssh.SshParameters[]",
+ "allDeclaredFields":true,
+ "allPublicMethods":true,
+ "allDeclaredConstructors":true,
+ "allPublicConstructors":true,
+ "allDeclaredClasses":true,
+ "allPublicClasses":true
+},
+{
+ "name":"io.titandata.remote.ssh.SshRemote",
+ "allDeclaredFields":true,
+ "allPublicMethods":true,
+ "allDeclaredConstructors":true,
+ "allPublicConstructors":true,
+ "allDeclaredClasses":true,
+ "allPublicClasses":true
+},
+{
+ "name":"io.titandata.remote.ssh.SshRemote[]",
"allDeclaredFields":true,
"allPublicMethods":true,
"allDeclaredConstructors":true,
diff --git a/pom.xml b/pom.xml
index 4a46cf2e..80ef0d15 100644
--- a/pom.xml
+++ b/pom.xml
@@ -7,7 +7,7 @@
titan
Titan CLI
- 0.3.2
+ 0.3.3
1.8
@@ -123,7 +123,7 @@
io.titandata
titan-client
- 0.4.4
+ 0.4.5
diff --git a/src/main/kotlin/io/titandata/titan/providers/Local.kt b/src/main/kotlin/io/titandata/titan/providers/Local.kt
index 46dac963..b98403d8 100644
--- a/src/main/kotlin/io/titandata/titan/providers/Local.kt
+++ b/src/main/kotlin/io/titandata/titan/providers/Local.kt
@@ -18,7 +18,7 @@ data class Container (
)
class Local: Provider {
- private val titanServerVersion = "0.4.4"
+ private val titanServerVersion = "0.4.5"
private val dockerRegistryUrl = "titandata"
private val httpHandler = HttpHandler()
diff --git a/src/main/kotlin/io/titandata/titan/providers/local/Commit.kt b/src/main/kotlin/io/titandata/titan/providers/local/Commit.kt
index 4c169f95..1945044d 100644
--- a/src/main/kotlin/io/titandata/titan/providers/local/Commit.kt
+++ b/src/main/kotlin/io/titandata/titan/providers/local/Commit.kt
@@ -23,7 +23,9 @@ class Commit (
"email" to email,
"message" to message!!,
"container" to repoMetadata["container"]!!,
- "repoTags" to repoMetadata["repoTags"]!!,
+ "image" to repoMetadata["image"]!!,
+ "tag" to repoMetadata["tag"]!!,
+ "digest" to repoMetadata["digest"]!!,
"runtime" to repoMetadata["runtime"]!!
)
val commit = Commit(uuid, metadata)
@@ -31,4 +33,5 @@ class Commit (
val hash = response.id
println("Commit $hash")
}
+
}
\ No newline at end of file
diff --git a/src/main/kotlin/io/titandata/titan/providers/local/RemoteLog.kt b/src/main/kotlin/io/titandata/titan/providers/local/RemoteLog.kt
index 25cf1d11..78df328e 100644
--- a/src/main/kotlin/io/titandata/titan/providers/local/RemoteLog.kt
+++ b/src/main/kotlin/io/titandata/titan/providers/local/RemoteLog.kt
@@ -7,7 +7,7 @@ package io.titandata.titan.providers.local
import io.titandata.client.apis.RemotesApi
import io.titandata.client.infrastructure.ClientException
import io.titandata.serialization.RemoteUtil
-import io.titandata.models.NopRemote
+import io.titandata.remote.nop.NopRemote
import io.titandata.models.Remote
class RemoteLog (
diff --git a/src/main/kotlin/io/titandata/titan/providers/local/Run.kt b/src/main/kotlin/io/titandata/titan/providers/local/Run.kt
index df11f25b..0535cca2 100644
--- a/src/main/kotlin/io/titandata/titan/providers/local/Run.kt
+++ b/src/main/kotlin/io/titandata/titan/providers/local/Run.kt
@@ -4,7 +4,6 @@
package io.titandata.titan.providers.local
-import com.google.gson.JsonObject
import io.titandata.client.apis.RepositoriesApi
import io.titandata.titan.clients.Docker
import io.titandata.titan.clients.Docker.Companion.fetchName
@@ -28,14 +27,20 @@ class Run (
if(containerName.contains("/")) {
exit("Container name cannot contain a slash",1)
}
- val image = arguments.last()
+ val imageArray = arguments.last().split(":")
+ val image = imageArray[0]
+ val tag = if (imageArray[1].isNullOrEmpty()) {
+ "latest"
+ } else {
+ imageArray[1]
+ }
var imageInfo: JSONObject? = null
try {
- imageInfo = docker.inspectImage(image)
+ imageInfo = docker.inspectImage("$image:$tag")
} catch (e: CommandException) {
- docker.pull(image)
- imageInfo = docker.inspectImage(image)
+ docker.pull("$image:$tag")
+ imageInfo = docker.inspectImage("$image:$tag")
}
if (imageInfo == null) {
@@ -65,21 +70,29 @@ class Run (
argumentEdit.removeAt((argumentEdit.indexOf("--name") + 1))
argumentEdit.removeAt(argumentEdit.indexOf("--name"))
}
- if (argumentEdit.contains(image)) {
- argumentEdit.removeAt(argumentEdit.indexOf(image))
+ if (argumentEdit.contains("$image:$tag")) {
+ argumentEdit.removeAt(argumentEdit.indexOf("$image:$tag"))
}
argList.add("--name")
argList.add(containerName)
argList.addAll(argumentEdit)
- val imageSHA = imageInfo.getJSONObject("Config").getString("Image")
+ val repoDigest = imageInfo.optJSONArray("RepoDigests")[0] as String
+ val dockerRunCommand = if(repoDigest.isNullOrEmpty()) {
+ "$image:$tag"
+ } else {
+ repoDigest
+ }
val metadata = mapOf(
- "container" to imageSHA,
- "repoTags" to imageInfo.getJSONArray("RepoTags")[0],
+ "container" to dockerRunCommand,
+ "image" to image,
+ "tag" to tag,
+ "digest" to repoDigest,
"runtime" to argList.toString()
)
+
val updateRepo = Repository(containerName, metadata)
repositoriesApi.updateRepository(containerName, updateRepo)
- docker.run(imageSHA, "", argList)
+ docker.run(dockerRunCommand, "", argList)
println("Running controlled container $containerName")
}
}
\ No newline at end of file
diff --git a/src/main/kotlin/io/titandata/titan/providers/local/Status.kt b/src/main/kotlin/io/titandata/titan/providers/local/Status.kt
index db4d8db1..dffbaee9 100644
--- a/src/main/kotlin/io/titandata/titan/providers/local/Status.kt
+++ b/src/main/kotlin/io/titandata/titan/providers/local/Status.kt
@@ -5,22 +5,40 @@
package io.titandata.titan.providers.local
import io.titandata.titan.providers.Container
+import io.titandata.client.apis.RepositoriesApi
+import java.text.DecimalFormat
+import kotlin.math.log10
class Status (
- private val getContainersStatus: () -> List
+ private val getContainersStatus: () -> List,
+ private val repositoriesApi: RepositoriesApi = RepositoriesApi()
){
+ private val n = System.lineSeparator()
+
+ /**
+ * https://stackoverflow.com/a/5599842
+ */
+ private fun readableFileSize(size: Long): String {
+ if (size <= 0) return "0"
+ val units = arrayOf("Bi", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB")
+ val digitGroups = (log10(size.toDouble()) / log10(1024.0)).toInt()
+ return DecimalFormat("#,##0.#").format(size / Math.pow(1024.0, digitGroups.toDouble())) + " " + units[digitGroups]
+ }
+
fun status(container: String) {
+ val status = repositoriesApi.getRepositoryStatus(container)
for(cont in getContainersStatus()) {
if(container == cont.name) {
- println("Status: ${cont.status}")
+ System.out.printf("%15s %s${n}", "Status: ", cont.status)
}
}
- println("*** SAMPLE STATUS ***")
- println("Size: 5.4GiB")
- println("Current Head: d3f4c1")
- println("Volumes:")
- println(" 1.23GiB /var/lib/postgres/data")
- println("Operations: None")
- println("*** SAMPLE STATUS ***")
+ System.out.printf("%15s %s${n}", "Logical Size: ", readableFileSize(status.logicalSize))
+ System.out.printf("%15s %s${n}", "Actual Size: ", readableFileSize(status.actualSize))
+ System.out.printf("%15s %s${n}", "Last Commit: ", status.lastCommit)
+ println()
+ System.out.printf("%-30s %-10s %s${n}", "Volume", "Logical", "Actual")
+ for (volume in status.volumeStatus) {
+ System.out.printf("%-30s %-10s %s${n}", volume.properties["path"], readableFileSize(volume.logicalSize), readableFileSize(volume.actualSize))
+ }
}
}
\ No newline at end of file
diff --git a/src/main/resources/VERSION b/src/main/resources/VERSION
index 9fc80f93..87a08711 100644
--- a/src/main/resources/VERSION
+++ b/src/main/resources/VERSION
@@ -1 +1 @@
-0.3.2
\ No newline at end of file
+0.3.3
\ No newline at end of file