You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
1010 B
Kotlin
37 lines
1010 B
Kotlin
2 years ago
|
package org.domaindrivenarchitecture.provs.server.application
|
||
2 years ago
|
|
||
2 years ago
|
import org.domaindrivenarchitecture.provs.framework.core.cli.TargetCliCommand
|
||
2 years ago
|
|
||
|
|
||
|
class ServerCliCommand(private val k3sType: String, val target: TargetCliCommand) {
|
||
|
fun isValid(): Boolean {
|
||
|
return target.isValid() && hasValidK3sType()
|
||
|
}
|
||
2 years ago
|
private fun hasValidK3sType(): Boolean {
|
||
2 years ago
|
return CliK3sArgumentsParser.K3sType.values().map { it.name }.contains(k3sType.uppercase())
|
||
|
}
|
||
|
fun type() = CliK3sArgumentsParser.K3sType.valueOf(k3sType.uppercase())
|
||
|
}
|
||
|
|
||
|
fun parseServerArguments(
|
||
|
programName: String = "java -jar provs.jar",
|
||
|
args: Array<String>
|
||
|
): ServerCliCommand {
|
||
|
val parser = CliK3sArgumentsParser(programName)
|
||
|
parser.parse(args)
|
||
|
|
||
|
return ServerCliCommand(
|
||
|
parser.type,
|
||
|
TargetCliCommand(
|
||
|
parser.localHost,
|
||
|
parser.remoteHost,
|
||
|
parser.userName,
|
||
|
parser.sshWithPasswordPrompt,
|
||
|
parser.sshWithGopassPath,
|
||
|
parser.sshWithKey
|
||
2 years ago
|
)
|
||
|
)
|
||
2 years ago
|
}
|
||
|
|
||
|
|