|
|
@ -1,6 +1,8 @@
|
|
|
|
package de.joshavg
|
|
|
|
package de.joshavg
|
|
|
|
|
|
|
|
|
|
|
|
import org.eclipse.microprofile.config.inject.ConfigProperty
|
|
|
|
import org.eclipse.microprofile.config.inject.ConfigProperty
|
|
|
|
|
|
|
|
import org.slf4j.Logger
|
|
|
|
|
|
|
|
import org.slf4j.LoggerFactory
|
|
|
|
import java.io.File
|
|
|
|
import java.io.File
|
|
|
|
import java.nio.file.Files
|
|
|
|
import java.nio.file.Files
|
|
|
|
import java.nio.file.Paths
|
|
|
|
import java.nio.file.Paths
|
|
|
@ -12,24 +14,38 @@ import javax.enterprise.context.ApplicationScoped
|
|
|
|
data class BuildConfig(val exec: String,
|
|
|
|
data class BuildConfig(val exec: String,
|
|
|
|
val user: String,
|
|
|
|
val user: String,
|
|
|
|
val dir: String,
|
|
|
|
val dir: String,
|
|
|
|
val key: String? = null) {
|
|
|
|
val key: String,
|
|
|
|
fun asPublic() = copy(key = null)
|
|
|
|
val env: Map<String, String>) {
|
|
|
|
|
|
|
|
fun asPublic() = copy(key = "")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ApplicationScoped
|
|
|
|
@ApplicationScoped
|
|
|
|
class Builds(@ConfigProperty(name = "ALFRED_HOME")
|
|
|
|
class Builds(@ConfigProperty(name = "ALFRED_HOME")
|
|
|
|
val home: String) {
|
|
|
|
private val home: String) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private val logger: Logger = LoggerFactory.getLogger(this::class.java)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
init {
|
|
|
|
|
|
|
|
logger.info("ALFRED_HOME is $home")
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fun buildConfig(build: String): BuildConfig {
|
|
|
|
fun buildConfig(build: String): BuildConfig {
|
|
|
|
val path = Paths.get(home, "builds", "$build.properties")
|
|
|
|
val path = Paths.get(home, "builds", "$build.properties")
|
|
|
|
val props = Properties()
|
|
|
|
val props = Properties()
|
|
|
|
props.load(path.toFile().inputStream())
|
|
|
|
props.load(path.toFile().inputStream())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val env = props
|
|
|
|
|
|
|
|
.entries
|
|
|
|
|
|
|
|
.filter { it.key.toString() == it.key.toString().toUpperCase() }
|
|
|
|
|
|
|
|
.map { Pair(it.key.toString(), it.value.toString()) }
|
|
|
|
|
|
|
|
.toMap()
|
|
|
|
|
|
|
|
|
|
|
|
return BuildConfig(
|
|
|
|
return BuildConfig(
|
|
|
|
exec = props.getProperty("exec"),
|
|
|
|
exec = props.getProperty("exec"),
|
|
|
|
user = props.getProperty("user"),
|
|
|
|
user = props.getProperty("user"),
|
|
|
|
dir = props.getProperty("dir"),
|
|
|
|
dir = props.getProperty("dir"),
|
|
|
|
key = props.getProperty("key"))
|
|
|
|
key = props.getProperty("key") ?: "",
|
|
|
|
|
|
|
|
env = env)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fun createLogFile(build: String): File {
|
|
|
|
fun createLogFile(build: String): File {
|
|
|
|