diff --git a/build.gradle b/build.gradle index 17eb9d4..7284287 100644 --- a/build.gradle +++ b/build.gradle @@ -18,7 +18,7 @@ apply plugin: "kotlinx-serialization" group = "org.domaindrivenarchitecture.provs" -version = "0.11.10-SNAPSHOT" +version = "release-0.11.10" repositories { mavenCentral() diff --git a/WorkplaceConfigExample.yaml b/desktop-config-example.yaml similarity index 100% rename from WorkplaceConfigExample.yaml rename to desktop-config-example.yaml 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 0457409..0b1c7a4 100644 --- a/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/application/Application.kt +++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/application/Application.kt @@ -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) { @@ -28,7 +28,7 @@ fun main(args: Array) { } 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" ) } diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/domain/DesktopService.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/domain/DesktopService.kt index 45e0257..89e372b 100644 --- a/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/domain/DesktopService.kt +++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/domain/DesktopService.kt @@ -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) diff --git a/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/DesktopConfigRepository.kt b/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/DesktopConfigRepository.kt index 1be7b57..e5cfafe 100644 --- a/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/DesktopConfigRepository.kt +++ b/src/main/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/DesktopConfigRepository.kt @@ -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() diff --git a/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/application/CliWorkplaceKtTest.kt b/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/application/ApplicationKtTest.kt similarity index 84% rename from src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/application/CliWorkplaceKtTest.kt rename to src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/application/ApplicationKtTest.kt index 168a15d..3c75643 100644 --- a/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/application/CliWorkplaceKtTest.kt +++ b/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/application/ApplicationKtTest.kt @@ -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().provisionWorkplace(any(), any(), any(), any(), any(), ) } returns ProvResult( + mockkStatic(Prov::provisionDesktop) + every { any().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().provisionWorkplace( + any().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().provisionWorkplace(any(), any(), any(), any(), any(), ) } + verify(exactly = 0) { any().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().provisionWorkplace(any(), any(), any(), any(), any(), ) } + verify(exactly = 0) { any().provisionDesktop(any(), any(), any(), any(), any(), ) } } } \ No newline at end of file diff --git a/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/domain/ProvisionWorkplaceKtTest.kt b/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/domain/DesktopServiceKtTest.kt similarity index 56% rename from src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/domain/ProvisionWorkplaceKtTest.kt rename to src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/domain/DesktopServiceKtTest.kt index 0078676..d067320 100644 --- a/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/domain/ProvisionWorkplaceKtTest.kt +++ b/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/domain/DesktopServiceKtTest.kt @@ -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(), diff --git a/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/K3SDesktopConfigRepositoryKtTest.kt b/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/K3SDesktopConfigRepositoryKtTest.kt index ffd39b2..2bae6b4 100644 --- a/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/K3SDesktopConfigRepositoryKtTest.kt +++ b/src/test/kotlin/org/domaindrivenarchitecture/provs/desktop/infrastructure/K3SDesktopConfigRepositoryKtTest.kt @@ -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 { - 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) } diff --git a/src/test/kotlin/org/domaindrivenarchitecture/provs/framework/ubuntu/web/base/WebKtTest.kt b/src/test/kotlin/org/domaindrivenarchitecture/provs/framework/ubuntu/web/base/WebKtTest.kt index 983b8b7..9fc68d4 100644 --- a/src/test/kotlin/org/domaindrivenarchitecture/provs/framework/ubuntu/web/base/WebKtTest.kt +++ b/src/test/kotlin/org/domaindrivenarchitecture/provs/framework/ubuntu/web/base/WebKtTest.kt @@ -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") diff --git a/src/test/kotlin/org/domaindrivenarchitecture/provs/server/infrastructure/GrafanaAgentRepositoryKtTest.kt b/src/test/kotlin/org/domaindrivenarchitecture/provs/server/infrastructure/GrafanaAgentRepositoryKtTest.kt index 06836c1..8c752a1 100644 --- a/src/test/kotlin/org/domaindrivenarchitecture/provs/server/infrastructure/GrafanaAgentRepositoryKtTest.kt +++ b/src/test/kotlin/org/domaindrivenarchitecture/provs/server/infrastructure/GrafanaAgentRepositoryKtTest.kt @@ -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) diff --git a/src/test/kotlin/org/domaindrivenarchitecture/provs/server/infrastructure/K3sConfigRepositoryTest.kt b/src/test/kotlin/org/domaindrivenarchitecture/provs/server/infrastructure/K3sConfigRepositoryTest.kt index f586ee9..0640d6c 100644 --- a/src/test/kotlin/org/domaindrivenarchitecture/provs/server/infrastructure/K3sConfigRepositoryTest.kt +++ b/src/test/kotlin/org/domaindrivenarchitecture/provs/server/infrastructure/K3sConfigRepositoryTest.kt @@ -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 { - 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) } diff --git a/src/test/resources/WorkplaceConfigExample.json b/src/test/resources/desktop-config-example.json similarity index 100% rename from src/test/resources/WorkplaceConfigExample.json rename to src/test/resources/desktop-config-example.json diff --git a/src/test/resources/InvalidWorkplaceConfig.yaml b/src/test/resources/invalid-desktop-config.yaml similarity index 100% rename from src/test/resources/InvalidWorkplaceConfig.yaml rename to src/test/resources/invalid-desktop-config.yaml diff --git a/src/test/resources/InvalidServerConfig.yaml b/src/test/resources/invalid-server-config.yaml similarity index 100% rename from src/test/resources/InvalidServerConfig.yaml rename to src/test/resources/invalid-server-config.yaml diff --git a/src/test/resources/k3sServerConfig.yaml b/src/test/resources/k3s-server-config.yaml similarity index 100% rename from src/test/resources/k3sServerConfig.yaml rename to src/test/resources/k3s-server-config.yaml diff --git a/src/test/resources/TestWorkplaceConfig.yaml b/src/test/resources/test-desktop-config.yaml similarity index 100% rename from src/test/resources/TestWorkplaceConfig.yaml rename to src/test/resources/test-desktop-config.yaml