lift ensureSudoWithoutPassword into task to avoid disconnect

This commit is contained in:
az 2023-04-12 17:05:54 +02:00
parent 2a5f0d95fb
commit c78cf8e3bf
2 changed files with 6 additions and 4 deletions

View file

@ -19,10 +19,12 @@ fun main(args: Array<String>) {
}
val prov = createProvInstance(cmd.target)
prov.ensureSudoWithoutPassword(cmd.target.remoteTarget()?.password)
try {
provisionDesktopCommand(prov, cmd)
prov.task {
ensureSudoWithoutPassword(cmd.target.remoteTarget()?.password)
provisionDesktopCommand(cmd)
}
} catch (e: SerializationException) {
println(
"Error: File \"${cmd.configFile?.fileName}\" has an invalid format and or invalid data.\n"

View file

@ -12,12 +12,12 @@ import org.domaindrivenarchitecture.provs.framework.ubuntu.keys.provisionKeys
import org.domaindrivenarchitecture.provs.framework.ubuntu.user.base.currentUserCanSudoWithoutPassword
import org.domaindrivenarchitecture.provs.framework.ubuntu.user.base.whoami
internal fun provisionDesktopCommand(prov: Prov, cmd: DesktopCliCommand) {
internal fun Prov.provisionDesktopCommand(cmd: DesktopCliCommand) = task {
// retrieve config
val conf = if (cmd.configFile != null) getConfig(cmd.configFile.fileName) else DesktopConfig()
prov.provisionDesktop(
provisionDesktop(
cmd.type,
conf.ssh?.keyPair(),
conf.gpg?.keyPair(),