Added 'only' option and ms-teams

merge-requests/1/merge
Clemens Geibel 2 years ago
parent 3b77038bd4
commit f219e70d83

@ -6,6 +6,7 @@ import org.domaindrivenarchitecture.provs.configuration.application.CliTargetPar
import org.domaindrivenarchitecture.provs.configuration.domain.ConfigFileName
import org.domaindrivenarchitecture.provs.configuration.domain.TargetCliCommand
import org.domaindrivenarchitecture.provs.desktop.domain.DesktopCliCommand
import org.domaindrivenarchitecture.provs.desktop.domain.DesktopSubmodule
import org.domaindrivenarchitecture.provs.desktop.domain.DesktopType
@ -44,10 +45,17 @@ open class CliArgumentsParser(name: String) : CliTargetParser(name) {
"c",
"the filename containing the yaml config",
)
val only by option(
ArgType.Choice<DesktopSubmodule>(),
"only",
"o",
"provisions only parts ",
)
override fun execute() {
configFileName = cliConfigFileName?.let { ConfigFileName(it) }
parsed = true
submodules = if (only != null) listOf(only!!.name.lowercase()) else null
}
}

@ -15,9 +15,15 @@ import org.domaindrivenarchitecture.provs.framework.ubuntu.user.base.whoami
fun provisionDesktop(prov: Prov, cmd: DesktopCliCommand) {
val submodules = cmd.submodules
// retrieve config
val conf = if (cmd.configFile != null) getConfig(cmd.configFile.fileName) else DesktopConfig()
prov.provisionWorkplace(cmd.type, conf.ssh?.keyPair(), conf.gpg?.keyPair(), conf.gitUserName, conf.gitEmail)
if (submodules == null) {
prov.provisionWorkplace(cmd.type, conf.ssh?.keyPair(), conf.gpg?.keyPair(), conf.gitUserName, conf.gitEmail)
} else {
prov.provisionDesktopSubmodules(submodules)
}
}
@ -111,3 +117,12 @@ fun Prov.provisionWorkplace(
}
ProvResult(true)
}
private fun Prov.provisionDesktopSubmodules(
submodules: List<String>,
) = task {
if (submodules.contains(DesktopSubmodule.TEAMS.name.lowercase())) {
installMsTeams()
}
}

@ -0,0 +1,5 @@
package org.domaindrivenarchitecture.provs.desktop.domain
enum class DesktopSubmodule {
TEAMS
}

@ -0,0 +1,14 @@
package org.domaindrivenarchitecture.provs.desktop.infrastructure
import org.domaindrivenarchitecture.provs.framework.core.Prov
import org.domaindrivenarchitecture.provs.framework.ubuntu.filesystem.base.createDir
import org.domaindrivenarchitecture.provs.framework.ubuntu.web.base.downloadFromURL
/**
* ATTENTION: Download URL might be only valid for a limited time and thus might not be working.
*/
fun Prov.installCitrixWorkspaceApp() = task {
downloadFromURL("https://downloads.citrix.com/20976/linuxx64-22.5.0.16.tar.gz?__gda__=exp=1654847726~acl=/*~hmac=be248338ecd7c7de50950ff7825fc0a80577fef7d3610988c64391cff8eaca16", "xitrix.tar.gz", "/tmp")
createDir("xitrix", "/tmp")
cmd("tar -xf xitrix.tar.gz -C /tmp/xitrix")
}

@ -0,0 +1,13 @@
package org.domaindrivenarchitecture.provs.desktop.infrastructure
import org.domaindrivenarchitecture.provs.framework.core.Prov
import org.domaindrivenarchitecture.provs.framework.ubuntu.install.base.aptInstall
fun Prov.installMsTeams() = task {
aptInstall("curl")
cmd("curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -")
cmd("sudo sh -c 'echo \"deb [arch=amd64] https://packages.microsoft.com/repos/ms-teams stable main\" > /etc/apt/sources.list.d/teams.list'")
//cmd("sudo apt update")
aptInstall("teams")
//cmd("sudo apt install teams")
}

@ -14,4 +14,13 @@ internal class CliArgumentsParserTest {
assertEquals(null, cli.configFile)
assertEquals(true, cli.target.isValidLocalhost())
}
@Test
fun parse_cliCommand_with_only_submodule_teams_and_local_target() {
val cli = CliArgumentsParser("test").parseCommand(args = arrayOf("ide", "local", "-o", "teams"))
assertTrue(cli.isValid())
assertEquals(true, cli.target.isValidLocalhost())
assertEquals(true, cli.submodules?.contains("teams"))
}
}

@ -0,0 +1,19 @@
package org.domaindrivenarchitecture.provs.desktop.infrastructure
import org.domaindrivenarchitecture.provs.test.defaultTestContainer
import org.domaindrivenarchitecture.provs.test.tags.ContainerTest
import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.Test
class MsTeamsTest {
@ContainerTest
fun installMsTeams() {
// given
val a = defaultTestContainer()
// when
val res = a.task { installMsTeams() }
// then
assertTrue(res.success)
}
}
Loading…
Cancel
Save