[skip ci] add local check for sudo
This commit is contained in:
parent
c7ea95fbd4
commit
b25729e910
1 changed files with 14 additions and 3 deletions
|
@ -29,9 +29,9 @@ fun createProvInstance(
|
||||||
|
|
||||||
val remoteTarget = targetCommand.remoteTarget()
|
val remoteTarget = targetCommand.remoteTarget()
|
||||||
if (targetCommand.isValidLocalhost()) {
|
if (targetCommand.isValidLocalhost()) {
|
||||||
return local()
|
return createLocalProvInstance()
|
||||||
} else if (targetCommand.isValidRemote() && remoteTarget != null) {
|
} else if (targetCommand.isValidRemote() && remoteTarget != null) {
|
||||||
return createProvInstanceRemote(
|
return createRemoteProvInstance(
|
||||||
remoteTarget.host,
|
remoteTarget.host,
|
||||||
remoteTarget.user,
|
remoteTarget.user,
|
||||||
remoteTarget.password == null,
|
remoteTarget.password == null,
|
||||||
|
@ -47,7 +47,18 @@ fun createProvInstance(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createProvInstanceRemote(
|
|
||||||
|
private fun createLocalProvInstance(): Prov {
|
||||||
|
val prov = local()
|
||||||
|
if (!prov.currentUserCanSudo()) {
|
||||||
|
val password = PromptSecretSource("Please enter password to configure sudo without password in the future.").secret()
|
||||||
|
prov.makeUserSudoerWithNoSudoPasswordRequired(password)
|
||||||
|
}
|
||||||
|
return prov
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private fun createRemoteProvInstance(
|
||||||
host: String,
|
host: String,
|
||||||
remoteUser: String,
|
remoteUser: String,
|
||||||
sshWithKey: Boolean,
|
sshWithKey: Boolean,
|
||||||
|
|
Loading…
Reference in a new issue