refactrored desktop mappings
This commit is contained in:
parent
b265824b63
commit
a608382a58
1 changed files with 71 additions and 69 deletions
|
@ -15,15 +15,11 @@ 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()
|
||||
|
||||
if (submodules == null) {
|
||||
prov.provisionDesktop(cmd.type, conf.ssh?.keyPair(), conf.gpg?.keyPair(), conf.gitUserName, conf.gitEmail)
|
||||
} else {
|
||||
prov.provisionDesktopSubmodules(submodules)
|
||||
}
|
||||
prov.provisionDesktopImpl(cmd.type, conf.ssh?.keyPair(), conf.gpg?.keyPair(), conf.gitUserName, conf.gitEmail, cmd.submodules)
|
||||
}
|
||||
|
||||
|
||||
|
@ -35,36 +31,38 @@ fun provisionDesktop(prov: Prov, cmd: DesktopCliCommand) {
|
|||
*
|
||||
* Prerequisites: user must be able to sudo without entering the password
|
||||
*/
|
||||
fun Prov.provisionDesktop(
|
||||
fun Prov.provisionDesktopImpl(
|
||||
desktopType: DesktopType = DesktopType.BASIC,
|
||||
ssh: KeyPair? = null,
|
||||
gpg: KeyPair? = null,
|
||||
gitUserName: String? = null,
|
||||
gitEmail: String? = null,
|
||||
submodules: List<String>?
|
||||
) = task {
|
||||
|
||||
// TODO: jem - 2022-06-30: why?? We got already a typed var!
|
||||
DesktopType.valueOf(desktopType.name) // throws exception when desktopType.name is unknown
|
||||
|
||||
validatePrecondition()
|
||||
provisionBaseDesktop(gpg, ssh, gitUserName, gitEmail)
|
||||
provisionBaseDesktop(gpg, ssh, gitUserName, gitEmail, submodules)
|
||||
|
||||
if (desktopType == DesktopType.OFFICE || desktopType == DesktopType.IDE) {
|
||||
provisionOfficeDesktop()
|
||||
provisionOfficeDesktop(submodules)
|
||||
}
|
||||
if (desktopType == DesktopType.IDE) {
|
||||
provisionIdeDesktop()
|
||||
provisionIdeDesktop(submodules)
|
||||
}
|
||||
ProvResult(true)
|
||||
}
|
||||
|
||||
private fun Prov.validatePrecondition() {
|
||||
fun Prov.validatePrecondition() {
|
||||
if (!currentUserCanSudo()) {
|
||||
throw Exception("Current user ${whoami()} cannot execute sudo without entering a password! This is necessary to execute provisionDesktop")
|
||||
}
|
||||
}
|
||||
|
||||
private fun Prov.provisionIdeDesktop() {
|
||||
fun Prov.provisionIdeDesktop(submodules: List<String>?) {
|
||||
if (submodules != null) {
|
||||
aptInstall(JAVA)
|
||||
aptInstall(OPEN_VPM)
|
||||
aptInstall(OPENCONNECT)
|
||||
|
@ -78,9 +76,18 @@ private fun Prov.provisionIdeDesktop() {
|
|||
installIntelliJ()
|
||||
installDevOps()
|
||||
provisionPython()
|
||||
}
|
||||
}
|
||||
|
||||
private fun Prov.provisionOfficeDesktop() {
|
||||
fun Prov.provisionMSDesktop(submodules: List<String>?) {
|
||||
if (submodules?.contains(DesktopSubmodule.TEAMS.name.lowercase()) == true) {
|
||||
installMsTeams()
|
||||
} else {
|
||||
}
|
||||
}
|
||||
|
||||
fun Prov.provisionOfficeDesktop(submodules: List<String>?) {
|
||||
if (submodules != null) {
|
||||
aptInstall(ZIP_UTILS)
|
||||
aptInstall(BROWSER)
|
||||
aptInstall(EMAIL_CLIENT)
|
||||
|
@ -96,14 +103,17 @@ private fun Prov.provisionOfficeDesktop() {
|
|||
}
|
||||
|
||||
aptInstall(SPELLCHECKING_DE)
|
||||
}
|
||||
}
|
||||
|
||||
private fun Prov.provisionBaseDesktop(
|
||||
gpg: KeyPair?,
|
||||
ssh: KeyPair?,
|
||||
gitUserName: String?,
|
||||
gitEmail: String?
|
||||
gitEmail: String?,
|
||||
submodules: List<String>?
|
||||
) {
|
||||
if (submodules != null) {
|
||||
aptInstall(KEY_MANAGEMENT)
|
||||
aptInstall(VERSION_MANAGEMENT)
|
||||
aptInstall(NETWORK_TOOLS)
|
||||
|
@ -129,13 +139,5 @@ private fun Prov.provisionBaseDesktop(
|
|||
|
||||
configureNoSwappiness()
|
||||
configureBash()
|
||||
}
|
||||
|
||||
private fun Prov.provisionDesktopSubmodules(
|
||||
submodules: List<String>,
|
||||
) = task {
|
||||
|
||||
if (submodules.contains(DesktopSubmodule.TEAMS.name.lowercase())) {
|
||||
installMsTeams()
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue