release-0.11.10 - rename workplace to desktop

merge-requests/1/merge release-0.11.10
ansgarz 2 years ago
parent bcd43a95be
commit bf3a8db4c0

@ -18,7 +18,7 @@ apply plugin: "kotlinx-serialization"
group = "org.domaindrivenarchitecture.provs"
version = "0.11.10-SNAPSHOT"
version = "release-0.11.10"
repositories {
mavenCentral()

@ -7,7 +7,7 @@ import java.io.FileNotFoundException
import kotlin.system.exitProcess
/**
* Provisions a desktop workplace locally or on a remote machine. Use option -h for help.
* Provisions desktop software (office and/or ide depending on type) locally or on a remote machine. Use option -h for help.
*/
fun main(args: Array<String>) {
@ -28,7 +28,7 @@ fun main(args: Array<String>) {
} catch (e: FileNotFoundException) {
println(
"Error: File\u001b[31m ${cmd.configFile?.fileName} \u001b[0m was not found.\n" +
"Pls copy file \u001B[31m WorkplaceConfigExample.yaml \u001B[0m to file \u001B[31m ${cmd.configFile?.fileName} \u001B[0m " +
"Pls copy file \u001B[31m desktop-config-example.yaml \u001B[0m to file \u001B[31m ${cmd.configFile?.fileName} \u001B[0m " +
"and change the content according to your needs.\n"
)
}

@ -20,7 +20,7 @@ fun provisionDesktop(prov: Prov, cmd: DesktopCliCommand) {
val conf = if (cmd.configFile != null) getConfig(cmd.configFile.fileName) else DesktopConfig()
if (submodules == null) {
prov.provisionWorkplace(cmd.type, conf.ssh?.keyPair(), conf.gpg?.keyPair(), conf.gitUserName, conf.gitEmail)
prov.provisionDesktop(cmd.type, conf.ssh?.keyPair(), conf.gpg?.keyPair(), conf.gitUserName, conf.gitEmail)
} else {
prov.provisionDesktopSubmodules(submodules)
}
@ -28,14 +28,14 @@ fun provisionDesktop(prov: Prov, cmd: DesktopCliCommand) {
/**
* Provisions software and configurations for a personal workplace.
* Provisions software and configurations for a personal desktop.
* Offers the possibility to choose between different types.
* Type OFFICE installs office-related software like Thunderbird, LibreOffice, and much more.
* Type IDE provides additional software for a development environment, such as Visual Studio Code, IntelliJ, etc.
*
* Prerequisites: user must be able to sudo without entering the password
*/
fun Prov.provisionWorkplace(
fun Prov.provisionDesktop(
desktopType: DesktopType = DesktopType.BASIC,
ssh: KeyPair? = null,
gpg: KeyPair? = null,
@ -44,7 +44,7 @@ fun Prov.provisionWorkplace(
) = task {
if (!currentUserCanSudo()) {
throw Exception("Current user ${whoami()} cannot execute sudo without entering a password! This is necessary to execute provisionWorkplace")
throw Exception("Current user ${whoami()} cannot execute sudo without entering a password! This is necessary to execute provisionDesktop")
}
aptInstall(KEY_MANAGEMENT)

@ -8,7 +8,7 @@ import java.io.FileWriter
/**
* Returns WorkplaceConfig; data for config is read from specified file.
* Returns DesktopConfig; data for config is read from specified file.
* Throws exceptions FileNotFoundException, SerializationException if file is not found resp. cannot be parsed.
*/
internal fun getConfig(filename: String = "desktop-config.yaml"): DesktopConfig = readFromFile(filename).yamlToType()

@ -7,7 +7,7 @@ import org.domaindrivenarchitecture.provs.configuration.domain.TargetCliCommand
import org.domaindrivenarchitecture.provs.desktop.domain.DesktopCliCommand
import org.domaindrivenarchitecture.provs.desktop.domain.DesktopConfig
import org.domaindrivenarchitecture.provs.desktop.domain.DesktopType
import org.domaindrivenarchitecture.provs.desktop.domain.provisionWorkplace
import org.domaindrivenarchitecture.provs.desktop.domain.provisionDesktop
import org.domaindrivenarchitecture.provs.desktop.infrastructure.getConfig
import org.domaindrivenarchitecture.provs.framework.core.*
import org.domaindrivenarchitecture.provs.framework.core.cli.retrievePassword
@ -20,7 +20,7 @@ import org.junit.jupiter.api.Test
import java.io.ByteArrayOutputStream
import java.io.PrintStream
internal class CliWorkplaceKtTest {
internal class ApplicationKtTest {
companion object {
@ -31,6 +31,7 @@ internal class CliWorkplaceKtTest {
ConfigFileName("bla")
)
@Suppress("unused") // false positive
@BeforeAll
@JvmStatic
internal fun beforeAll() {
@ -48,8 +49,8 @@ internal class CliWorkplaceKtTest {
mockkStatic(::getConfig)
every { getConfig("testconfig.yaml") } returns testConfig
mockkStatic(Prov::provisionWorkplace)
every { any<Prov>().provisionWorkplace(any(), any(), any(), any(), any(), ) } returns ProvResult(
mockkStatic(Prov::provisionDesktop)
every { any<Prov>().provisionDesktop(any(), any(), any(), any(), any(), ) } returns ProvResult(
true,
cmd = "mocked command"
)
@ -58,6 +59,7 @@ internal class CliWorkplaceKtTest {
every { retrievePassword(any()) } returns Secret("sec")
}
@Suppress("unused") // false positive
@AfterAll
@JvmStatic
internal fun afterAll() {
@ -65,13 +67,13 @@ internal class CliWorkplaceKtTest {
unmockkStatic(::local)
unmockkStatic(::remote)
unmockkStatic(::getConfig)
unmockkStatic(Prov::provisionWorkplace)
unmockkStatic(Prov::provisionDesktop)
unmockkStatic(::retrievePassword)
}
}
@Test
fun provision_workplace_remotely() {
fun provision_desktop_remotely() {
// when
main(arrayOf("basic", "user123:sec@host123.xyz", "-c", "testconfig.yaml"))
@ -79,7 +81,7 @@ internal class CliWorkplaceKtTest {
// then
verify { remote("host123.xyz", "user123", Secret("sec"), any()) }
verify {
any<Prov>().provisionWorkplace(
any<Prov>().provisionDesktop(
DesktopType.BASIC,
null,
null,
@ -110,10 +112,10 @@ internal class CliWorkplaceKtTest {
System.setErr(originalErr)
val expectedOutput =
"Error: File\u001B[31m idontexist.yaml \u001B[0m was not found.Pls copy file \u001B[31m WorkplaceConfigExample.yaml \u001B[0m to file \u001B[31m idontexist.yaml \u001B[0m and change the content according to your needs."
"Error: File\u001B[31m idontexist.yaml \u001B[0m was not found.Pls copy file \u001B[31m desktop-config-example.yaml \u001B[0m to file \u001B[31m idontexist.yaml \u001B[0m and change the content according to your needs."
assertEquals(expectedOutput, outContent.toString().replace("\r", "").replace("\n", ""))
verify(exactly = 0) { any<Prov>().provisionWorkplace(any(), any(), any(), any(), any(), ) }
verify(exactly = 0) { any<Prov>().provisionDesktop(any(), any(), any(), any(), any(), ) }
}
@Test
@ -130,16 +132,16 @@ internal class CliWorkplaceKtTest {
System.setErr(PrintStream(errContent))
// when
main(arrayOf("basic", "someuser@remotehost", "-c", "src/test/resources/InvalidWorkplaceConfig.yaml"))
main(arrayOf("basic", "someuser@remotehost", "-c", "src/test/resources/invalid-desktop-config.yaml"))
// then
System.setOut(originalOut)
System.setErr(originalErr)
val expectedOutput =
"Error: File \"src/test/resources/InvalidWorkplaceConfig.yaml\" has an invalid format and or invalid data."
"Error: File \"src/test/resources/invalid-desktop-config.yaml\" has an invalid format and or invalid data."
assertEquals(expectedOutput, outContent.toString().replace("\r", "").replace("\n", ""))
verify(exactly = 0) { any<Prov>().provisionWorkplace(any(), any(), any(), any(), any(), ) }
verify(exactly = 0) { any<Prov>().provisionDesktop(any(), any(), any(), any(), any(), ) }
}
}

@ -5,16 +5,16 @@ import org.domaindrivenarchitecture.provs.test.defaultTestContainer
import org.domaindrivenarchitecture.provs.test.tags.ExtensiveContainerTest
import org.junit.jupiter.api.Assertions.assertTrue
internal class ProvisionWorkplaceKtTest {
internal class DesktopServiceKtTest {
@ExtensiveContainerTest
fun provisionWorkplace() {
fun provisionDesktop() {
// given
val a = defaultTestContainer()
val prov = defaultTestContainer()
// when
// in order to test WorkplaceType.OFFICE: fix installing libreoffice for a fresh container as it hangs the first time but succeeds 2nd time
val res = a.provisionWorkplace(
// in order to test DesktopType.OFFICE: fix installing libreoffice for a fresh container as it hangs the first time but succeeds 2nd time
val res = prov.provisionDesktop(
DesktopType.BASIC,
gitUserName = "testuser",
gitEmail = "testuser@test.org",
@ -26,14 +26,14 @@ internal class ProvisionWorkplaceKtTest {
@ExtensiveContainerTest
fun provisionWorkplaceFromConfigFile() {
fun provisionDesktopFromConfigFile() {
// given
val a = defaultTestContainer()
val prov = defaultTestContainer()
// when
// in order to test WorkplaceType.OFFICE: fix installing libreoffice for a fresh container as it hangs the first time but succeeds 2nd time
val config = getConfig("src/test/resources/WorkplaceConfigExample.json")
val res = a.provisionWorkplace(
// in order to test DesktopType.OFFICE: fix installing libreoffice for a fresh container as it hangs the first time but succeeds 2nd time
val config = getConfig("src/test/resources/desktop-config-example.json")
val res = prov.provisionDesktop(
DesktopType.BASIC,
config.ssh?.keyPair(),
config.gpg?.keyPair(),

@ -14,7 +14,7 @@ internal class K3SDesktopConfigRepositoryKtTest {
@Test
fun getConfig_successful() {
// when
val config = getConfig("src/test/resources/TestWorkplaceConfig.yaml")
val config = getConfig("src/test/resources/test-desktop-config.yaml")
// then
assertEquals("username", config.gitUserName)
@ -32,7 +32,7 @@ internal class K3SDesktopConfigRepositoryKtTest {
@Test
fun getConfig_fails_due_to_invalidProperty() {
val exception = assertThrows<InvalidPropertyValueException> {
getConfig("src/test/resources/InvalidWorkplaceConfig.yaml")
getConfig("src/test/resources/invalid-desktop-config.yaml")
}
assertEquals("Value for 'sourceType' is invalid: Value 'xxx' is not a valid option, permitted choices are: FILE, GOPASS, PASS, PLAIN, PROMPT", exception.message)
}

@ -115,7 +115,7 @@ internal class WebKtTest {
}
@Test
fun isIp4_recognizes_Ip_correctly() {
fun isIp4_recognizes_ip_correctly() {
// when
val res1 = isIp4("123.123.123.123")
val res2 = isIp4("123.abc.123.123")
@ -128,7 +128,7 @@ internal class WebKtTest {
}
@Test
fun isIp6_recognizes_Ip_correctly() {
fun isIp6_recognizes_ip_correctly() {
// when
val res1 = isIp6("2001:db8:3333:4444:5555:6666:7777:8888")
val res2 = isIp6("2001:db8:3333:4444:CCCC:DDDD:EEEE:FFFF")

@ -28,7 +28,7 @@ internal class GrafanaAgentRepositoryKtTest {
@Test
fun findK8sGrafanaConfig_returns_null_if_no_grafan_data_available() {
// when
val config = findK8sGrafanaConfig(ConfigFileName("src/test/resources/k3sServerConfig.yaml"))
val config = findK8sGrafanaConfig(ConfigFileName("src/test/resources/k3s-server-config.yaml"))
// then
assertEquals(null, config)

@ -17,7 +17,7 @@ internal class K3sConfigRepositoryTest {
@Test
fun getConfig_successful() {
// when
val config = getK3sConfig(ConfigFileName("src/test/resources/k3sServerConfig.yaml"))
val config = getK3sConfig(ConfigFileName("src/test/resources/k3s-server-config.yaml"))
// then
assertEquals(
@ -38,7 +38,7 @@ internal class K3sConfigRepositoryTest {
@Test
fun getConfig_fails_due_to_missing_property() {
val exception = assertThrows<SerializationException> {
getK3sConfig(ConfigFileName("src/test/resources/InvalidWorkplaceConfig.yaml"))
getK3sConfig(ConfigFileName("src/test/resources/invalid-desktop-config.yaml"))
}
assertEquals("Fields [fqdn, node] are required for type with serial name 'org.domaindrivenarchitecture.provs.server.domain.k3s.K3sConfig', but they were missing", exception.message)
}

Loading…
Cancel
Save