diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/application/Application.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/application/Application.kt index b08f513..6f40e37 100644 --- a/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/application/Application.kt +++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/application/Application.kt @@ -38,8 +38,8 @@ fun main(args: Array) { null } catch (e: FileNotFoundException) { println( - "Error: File\u001b[31m ${configFileName} \u001b[0m was not found.\n" + - "Pls copy file \u001B[31m desktop-config-example.yaml \u001B[0m to file \u001B[31m ${configFileName} \u001B[0m " + + "Error: File\u001b[31m $configFileName \u001b[0m was not found.\n" + + "Pls copy file \u001B[31m desktop-config-example.yaml \u001B[0m to file \u001B[31m $configFileName \u001B[0m " + "and change the content according to your needs." ) null diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/framework/core/docker/HostDocker.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/framework/core/docker/HostDocker.kt index 460a1df..9bc449e 100644 --- a/src/main/kotlin/org/domaindrivenarchitecture/provs/framework/core/docker/HostDocker.kt +++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/framework/core/docker/HostDocker.kt @@ -6,7 +6,7 @@ import org.domaindrivenarchitecture.provs.framework.core.docker.dockerimages.Doc import org.domaindrivenarchitecture.provs.framework.core.docker.platforms.* import org.domaindrivenarchitecture.provs.framework.core.platforms.UbuntuProv import org.domaindrivenarchitecture.provs.framework.core.processors.ContainerStartMode -import org.domaindrivenarchitecture.provs.framework.core.docker.platforms.* + private const val DOCKER_NOT_SUPPORTED = "docker not yet supported for " @@ -17,7 +17,7 @@ fun Prov.dockerProvideImage(image: DockerImage, skipIfExisting: Boolean = true, if (this is UbuntuProv) { return this.dockerProvideImagePlatform(image, skipIfExisting, sudo) } else { - throw RuntimeException(DOCKER_NOT_SUPPORTED + (this as UbuntuProv).javaClass) + throw RuntimeException(DOCKER_NOT_SUPPORTED + this.javaClass) } } @@ -28,7 +28,7 @@ fun Prov.dockerImageExists(imageName: String, sudo: Boolean = true) : Boolean { if (this is UbuntuProv) { return this.dockerImageExistsPlatform(imageName, sudo) } else { - throw RuntimeException(DOCKER_NOT_SUPPORTED + (this as UbuntuProv).javaClass) + throw RuntimeException(DOCKER_NOT_SUPPORTED + this.javaClass) } } @@ -50,7 +50,7 @@ fun Prov.provideContainer( if (this is UbuntuProv) { return this.provideContainerPlatform(containerName, imageName, startMode, sudo, options, command) } else { - throw RuntimeException(DOCKER_NOT_SUPPORTED + (this as UbuntuProv).javaClass) + throw RuntimeException(DOCKER_NOT_SUPPORTED + this.javaClass) } } @@ -59,7 +59,7 @@ fun Prov.containerRuns(containerName: String, sudo: Boolean = true) : Boolean { if (this is UbuntuProv) { return this.containerRunsPlatform(containerName, sudo) } else { - throw RuntimeException(DOCKER_NOT_SUPPORTED + (this as UbuntuProv).javaClass) + throw RuntimeException(DOCKER_NOT_SUPPORTED + this.javaClass) } } @@ -72,7 +72,7 @@ fun Prov.runContainer( if (this is UbuntuProv) { return this.runContainerPlatform(containerName, imageName, sudo) } else { - throw RuntimeException(DOCKER_NOT_SUPPORTED + (this as UbuntuProv).javaClass) + throw RuntimeException(DOCKER_NOT_SUPPORTED + this.javaClass) } } @@ -84,16 +84,17 @@ fun Prov.exitAndRmContainer( if (this is UbuntuProv) { return this.exitAndRmContainerPlatform(containerName, sudo) } else { - throw RuntimeException(DOCKER_NOT_SUPPORTED + (this as UbuntuProv).javaClass) + throw RuntimeException(DOCKER_NOT_SUPPORTED + this.javaClass) } } +@Suppress("unused") fun Prov.containerExec(containerName: String, cmd: String, sudo: Boolean = true): ProvResult { if (this is UbuntuProv) { return this.containerExecPlatform(containerName, cmd, sudo) } else { - throw RuntimeException(DOCKER_NOT_SUPPORTED + (this as UbuntuProv).javaClass) + throw RuntimeException(DOCKER_NOT_SUPPORTED + this.javaClass) } } diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/framework/core/platforms/UbuntuProv.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/framework/core/platforms/UbuntuProv.kt index f2c8791..97eacc6 100644 --- a/src/main/kotlin/org/domaindrivenarchitecture/provs/framework/core/platforms/UbuntuProv.kt +++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/framework/core/platforms/UbuntuProv.kt @@ -30,13 +30,15 @@ open class UbuntuProv( } private fun buildCommand(vararg args: String): String { - return if (args.size == 1) + return if (args.size == 1) { args[0].escapeAndEncloseByDoubleQuoteForShell() - else - if (args.size == 3 && SHELL.equals(args[0]) && "-c".equals(args[1])) + } else { + if (args.size == 3 && SHELL == args[0] && "-c" == args[1]) { SHELL + " -c " + args[2].escapeAndEncloseByDoubleQuoteForShell() - else + } else { args.joinToString(separator = " ") + } + } } } diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/framework/ubuntu/filesystem/base/Filesystem.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/framework/ubuntu/filesystem/base/Filesystem.kt index 28dcb9e..8cf4415 100644 --- a/src/main/kotlin/org/domaindrivenarchitecture/provs/framework/ubuntu/filesystem/base/Filesystem.kt +++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/framework/ubuntu/filesystem/base/Filesystem.kt @@ -201,7 +201,7 @@ fun Prov.fileContentLargeFile(file: String, sudo: Boolean = false, chunkSize: In // check first chunk if (resultString == null) { if (!chunkResult.success) { - return resultString + return null } else { resultString = "" } diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/framework/ubuntu/secret/SecretSource.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/framework/ubuntu/secret/SecretSource.kt index a48d973..ae979ef 100644 --- a/src/main/kotlin/org/domaindrivenarchitecture/provs/framework/ubuntu/secret/SecretSource.kt +++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/framework/ubuntu/secret/SecretSource.kt @@ -13,7 +13,7 @@ abstract class SecretSource(protected val input: String) { @Serializable -enum class SecretSourceType() { +enum class SecretSourceType { PLAIN, FILE, PROMPT, PASS, GOPASS; diff --git a/src/test/kotlin/org/domaindrivenarchitecture/provs/server/infrastructure/K3sKtTest.kt b/src/test/kotlin/org/domaindrivenarchitecture/provs/server/infrastructure/K3sKtTest.kt index 60405a1..3ca6837 100644 --- a/src/test/kotlin/org/domaindrivenarchitecture/provs/server/infrastructure/K3sKtTest.kt +++ b/src/test/kotlin/org/domaindrivenarchitecture/provs/server/infrastructure/K3sKtTest.kt @@ -1,11 +1,7 @@ package org.domaindrivenarchitecture.provs.server.infrastructure -import org.domaindrivenarchitecture.provs.framework.core.Secret import org.domaindrivenarchitecture.provs.framework.core.local import org.domaindrivenarchitecture.provs.framework.core.remote -import org.domaindrivenarchitecture.provs.framework.ubuntu.filesystem.base.createDir -import org.domaindrivenarchitecture.provs.framework.ubuntu.filesystem.base.createSecretFile -import org.domaindrivenarchitecture.provs.framework.ubuntu.secret.secretSources.PromptSecretSource import org.domaindrivenarchitecture.provs.server.domain.k3s.K3sConfig import org.domaindrivenarchitecture.provs.server.domain.k3s.Node import org.domaindrivenarchitecture.provs.server.domain.k3s.provisionK3s @@ -14,6 +10,7 @@ import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import java.lang.Thread.sleep + class K3sKtTest { @Test // Extensive test, takes several minutes