|
|
|
@ -1,6 +1,8 @@
|
|
|
|
|
package de.joshavg
|
|
|
|
|
|
|
|
|
|
import org.eclipse.microprofile.config.inject.ConfigProperty
|
|
|
|
|
import org.slf4j.Logger
|
|
|
|
|
import org.slf4j.LoggerFactory
|
|
|
|
|
import java.io.File
|
|
|
|
|
import java.nio.file.Files
|
|
|
|
|
import java.nio.file.Paths
|
|
|
|
@ -12,24 +14,38 @@ import javax.enterprise.context.ApplicationScoped
|
|
|
|
|
data class BuildConfig(val exec: String,
|
|
|
|
|
val user: String,
|
|
|
|
|
val dir: String,
|
|
|
|
|
val key: String? = null) {
|
|
|
|
|
fun asPublic() = copy(key = null)
|
|
|
|
|
val key: String,
|
|
|
|
|
val env: Map<String, String>) {
|
|
|
|
|
fun asPublic() = copy(key = "")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApplicationScoped
|
|
|
|
|
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 {
|
|
|
|
|
val path = Paths.get(home, "builds", "$build.properties")
|
|
|
|
|
val props = Properties()
|
|
|
|
|
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(
|
|
|
|
|
exec = props.getProperty("exec"),
|
|
|
|
|
user = props.getProperty("user"),
|
|
|
|
|
dir = props.getProperty("dir"),
|
|
|
|
|
key = props.getProperty("key"))
|
|
|
|
|
key = props.getProperty("key") ?: "",
|
|
|
|
|
env = env)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun createLogFile(build: String): File {
|
|
|
|
|