From 32ed13759151b152eef9b6e5693dd14eeb2778f7 Mon Sep 17 00:00:00 2001 From: Logan Gorence Date: Thu, 23 Dec 2021 02:19:36 +0000 Subject: [PATCH] Move bifrost.yaml to foundation-bifrost. --- .../kubelet/foundation/bifrost/FoundationBifrostPlugin.kt | 6 +++++- .../src/main/resources/bifrost.yaml | 0 .../src/main/kotlin/cloud/kubelet/foundation/core/Util.kt | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) rename {foundation-core => foundation-bifrost}/src/main/resources/bifrost.yaml (100%) diff --git a/foundation-bifrost/src/main/kotlin/cloud/kubelet/foundation/bifrost/FoundationBifrostPlugin.kt b/foundation-bifrost/src/main/kotlin/cloud/kubelet/foundation/bifrost/FoundationBifrostPlugin.kt index 0159f75..9453650 100644 --- a/foundation-bifrost/src/main/kotlin/cloud/kubelet/foundation/bifrost/FoundationBifrostPlugin.kt +++ b/foundation-bifrost/src/main/kotlin/cloud/kubelet/foundation/bifrost/FoundationBifrostPlugin.kt @@ -35,7 +35,11 @@ class FoundationBifrostPlugin : JavaPlugin(), EventListener, Listener { val foundation = server.pluginManager.getPlugin("Foundation") as FoundationCorePlugin slF4JLogger.info("Plugin data path: ${foundation.pluginDataPath}") - val configPath = Util.copyDefaultConfig(slF4JLogger, foundation.pluginDataPath, "bifrost.yaml") + val configPath = Util.copyDefaultConfig( + slF4JLogger, + foundation.pluginDataPath, + "bifrost.yaml" + ) config = Yaml.default.decodeFromStream(BifrostConfig.serializer(), configPath.inputStream()) server.pluginManager.registerEvents(this, this) diff --git a/foundation-core/src/main/resources/bifrost.yaml b/foundation-bifrost/src/main/resources/bifrost.yaml similarity index 100% rename from foundation-core/src/main/resources/bifrost.yaml rename to foundation-bifrost/src/main/resources/bifrost.yaml diff --git a/foundation-core/src/main/kotlin/cloud/kubelet/foundation/core/Util.kt b/foundation-core/src/main/kotlin/cloud/kubelet/foundation/core/Util.kt index 00c7233..8349712 100644 --- a/foundation-core/src/main/kotlin/cloud/kubelet/foundation/core/Util.kt +++ b/foundation-core/src/main/kotlin/cloud/kubelet/foundation/core/Util.kt @@ -33,7 +33,7 @@ object Util { * @param resourceName Path to resource, it should be in the root of the `resources` directory, * without the leading slash. */ - fun copyDefaultConfig(log: Logger, targetPath: Path, resourceName: String): Path { + inline fun copyDefaultConfig(log: Logger, targetPath: Path, resourceName: String): Path { if (resourceName.startsWith("/")) { throw IllegalArgumentException("resourceName starts with slash") } @@ -48,7 +48,7 @@ object Util { return outPath } - val resourceStream = javaClass.getResourceAsStream("/$resourceName") + val resourceStream = T::class.java.getResourceAsStream("/$resourceName") ?: throw Exception("Configuration resource does not exist!") val outputStream = outFile.outputStream()