diff --git a/.idea/modules.xml b/.idea/modules.xml index e5828cd1..35ecce71 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -5,12 +5,12 @@ - - - - - - + + + + + + @@ -22,9 +22,9 @@ - - - + + + diff --git a/.idea/modules/packages/google-agones-sdk/bindings/java/shulker.packages.google-agones-sdk-bindings-java.iml b/.idea/modules/packages/google-agones-sdk/bindings/java/shulker.packages.google-agones-sdk.iml similarity index 55% rename from .idea/modules/packages/google-agones-sdk/bindings/java/shulker.packages.google-agones-sdk-bindings-java.iml rename to .idea/modules/packages/google-agones-sdk/bindings/java/shulker.packages.google-agones-sdk.iml index cb926e5c..097d4757 100644 --- a/.idea/modules/packages/google-agones-sdk/bindings/java/shulker.packages.google-agones-sdk-bindings-java.iml +++ b/.idea/modules/packages/google-agones-sdk/bindings/java/shulker.packages.google-agones-sdk.iml @@ -1,5 +1,5 @@ - + diff --git a/.idea/modules/packages/google-agones-sdk/bindings/java/shulker.packages.google-agones-sdk-bindings-java.main.iml b/.idea/modules/packages/google-agones-sdk/bindings/java/shulker.packages.google-agones-sdk.main.iml similarity index 87% rename from .idea/modules/packages/google-agones-sdk/bindings/java/shulker.packages.google-agones-sdk-bindings-java.main.iml rename to .idea/modules/packages/google-agones-sdk/bindings/java/shulker.packages.google-agones-sdk.main.iml index a545be7b..a23cc506 100644 --- a/.idea/modules/packages/google-agones-sdk/bindings/java/shulker.packages.google-agones-sdk-bindings-java.main.iml +++ b/.idea/modules/packages/google-agones-sdk/bindings/java/shulker.packages.google-agones-sdk.main.iml @@ -1,7 +1,7 @@ - + - + diff --git a/.idea/modules/packages/google-agones-sdk/bindings/java/shulker.packages.google-agones-sdk-bindings-java.test.iml b/.idea/modules/packages/google-agones-sdk/bindings/java/shulker.packages.google-agones-sdk.test.iml similarity index 83% rename from .idea/modules/packages/google-agones-sdk/bindings/java/shulker.packages.google-agones-sdk-bindings-java.test.iml rename to .idea/modules/packages/google-agones-sdk/bindings/java/shulker.packages.google-agones-sdk.test.iml index b07df0cf..621e29d7 100644 --- a/.idea/modules/packages/google-agones-sdk/bindings/java/shulker.packages.google-agones-sdk-bindings-java.test.iml +++ b/.idea/modules/packages/google-agones-sdk/bindings/java/shulker.packages.google-agones-sdk.test.iml @@ -1,12 +1,12 @@ - + - + - + @@ -31,5 +31,5 @@ - + \ No newline at end of file diff --git a/.idea/modules/packages/google-open-match-sdk/bindings/java/shulker.packages.google-open-match-sdk-bindings-java.iml b/.idea/modules/packages/google-open-match-sdk/bindings/java/shulker.packages.google-open-match-sdk.iml similarity index 62% rename from .idea/modules/packages/google-open-match-sdk/bindings/java/shulker.packages.google-open-match-sdk-bindings-java.iml rename to .idea/modules/packages/google-open-match-sdk/bindings/java/shulker.packages.google-open-match-sdk.iml index 928fcee5..0ec16f4e 100644 --- a/.idea/modules/packages/google-open-match-sdk/bindings/java/shulker.packages.google-open-match-sdk-bindings-java.iml +++ b/.idea/modules/packages/google-open-match-sdk/bindings/java/shulker.packages.google-open-match-sdk.iml @@ -1,5 +1,5 @@ - + diff --git a/.idea/modules/packages/google-open-match-sdk/bindings/java/shulker.packages.google-open-match-sdk-bindings-java.main.iml b/.idea/modules/packages/google-open-match-sdk/bindings/java/shulker.packages.google-open-match-sdk.main.iml similarity index 84% rename from .idea/modules/packages/google-open-match-sdk/bindings/java/shulker.packages.google-open-match-sdk-bindings-java.main.iml rename to .idea/modules/packages/google-open-match-sdk/bindings/java/shulker.packages.google-open-match-sdk.main.iml index 03d705a6..f66dbab1 100644 --- a/.idea/modules/packages/google-open-match-sdk/bindings/java/shulker.packages.google-open-match-sdk-bindings-java.main.iml +++ b/.idea/modules/packages/google-open-match-sdk/bindings/java/shulker.packages.google-open-match-sdk.main.iml @@ -1,15 +1,13 @@ - + - + - - - + diff --git a/.idea/modules/packages/google-open-match-sdk/bindings/java/shulker.packages.google-open-match-sdk-bindings-java.test.iml b/.idea/modules/packages/google-open-match-sdk/bindings/java/shulker.packages.google-open-match-sdk.test.iml similarity index 84% rename from .idea/modules/packages/google-open-match-sdk/bindings/java/shulker.packages.google-open-match-sdk-bindings-java.test.iml rename to .idea/modules/packages/google-open-match-sdk/bindings/java/shulker.packages.google-open-match-sdk.test.iml index 6d54ea04..c9c80fc8 100644 --- a/.idea/modules/packages/google-open-match-sdk/bindings/java/shulker.packages.google-open-match-sdk-bindings-java.test.iml +++ b/.idea/modules/packages/google-open-match-sdk/bindings/java/shulker.packages.google-open-match-sdk.test.iml @@ -1,12 +1,12 @@ - + - + - + @@ -31,5 +31,5 @@ - + \ No newline at end of file diff --git a/.idea/modules/packages/shulker-proxy-agent/shulker.packages.shulker-proxy-agent.bungeecord.iml b/.idea/modules/packages/shulker-proxy-agent/shulker.packages.shulker-proxy-agent.bungeecord.iml index a2604d53..9be27abd 100644 --- a/.idea/modules/packages/shulker-proxy-agent/shulker.packages.shulker-proxy-agent.bungeecord.iml +++ b/.idea/modules/packages/shulker-proxy-agent/shulker.packages.shulker-proxy-agent.bungeecord.iml @@ -1,5 +1,5 @@ - + @@ -81,9 +81,9 @@ + - - + @@ -102,8 +102,30 @@ + + + + + + + + + + + + + + + + + + + + + + @@ -129,37 +151,15 @@ - - - - - - - - - - - - - - - - - - - - + - - - diff --git a/.idea/modules/packages/shulker-proxy-agent/shulker.packages.shulker-proxy-agent.common.iml b/.idea/modules/packages/shulker-proxy-agent/shulker.packages.shulker-proxy-agent.common.iml index e298059e..1ed2809f 100644 --- a/.idea/modules/packages/shulker-proxy-agent/shulker.packages.shulker-proxy-agent.common.iml +++ b/.idea/modules/packages/shulker-proxy-agent/shulker.packages.shulker-proxy-agent.common.iml @@ -1,5 +1,5 @@ - + @@ -73,9 +73,9 @@ + - - + @@ -84,8 +84,22 @@ + + + + + + + + + + + + + + @@ -107,30 +121,16 @@ - - - - - - - - - - - - - - diff --git a/.idea/modules/packages/shulker-proxy-agent/shulker.packages.shulker-proxy-agent.iml b/.idea/modules/packages/shulker-proxy-agent/shulker.packages.shulker-proxy-agent.iml index 7f1e8c8e..af8d290e 100644 --- a/.idea/modules/packages/shulker-proxy-agent/shulker.packages.shulker-proxy-agent.iml +++ b/.idea/modules/packages/shulker-proxy-agent/shulker.packages.shulker-proxy-agent.iml @@ -1,5 +1,5 @@ - + diff --git a/.idea/modules/packages/shulker-proxy-agent/shulker.packages.shulker-proxy-agent.main.iml b/.idea/modules/packages/shulker-proxy-agent/shulker.packages.shulker-proxy-agent.main.iml index 1263ddef..5a3862eb 100644 --- a/.idea/modules/packages/shulker-proxy-agent/shulker.packages.shulker-proxy-agent.main.iml +++ b/.idea/modules/packages/shulker-proxy-agent/shulker.packages.shulker-proxy-agent.main.iml @@ -1,5 +1,5 @@ - + diff --git a/.idea/modules/packages/shulker-proxy-agent/shulker.packages.shulker-proxy-agent.test.iml b/.idea/modules/packages/shulker-proxy-agent/shulker.packages.shulker-proxy-agent.test.iml index 8389a8af..f5a9018c 100644 --- a/.idea/modules/packages/shulker-proxy-agent/shulker.packages.shulker-proxy-agent.test.iml +++ b/.idea/modules/packages/shulker-proxy-agent/shulker.packages.shulker-proxy-agent.test.iml @@ -1,5 +1,5 @@ - + diff --git a/.idea/modules/packages/shulker-proxy-agent/shulker.packages.shulker-proxy-agent.velocity.iml b/.idea/modules/packages/shulker-proxy-agent/shulker.packages.shulker-proxy-agent.velocity.iml index 879ee8ad..5eb27cf4 100644 --- a/.idea/modules/packages/shulker-proxy-agent/shulker.packages.shulker-proxy-agent.velocity.iml +++ b/.idea/modules/packages/shulker-proxy-agent/shulker.packages.shulker-proxy-agent.velocity.iml @@ -1,5 +1,5 @@ - + @@ -82,9 +82,9 @@ + - - + @@ -105,8 +105,25 @@ + + + + + + + + + + + + + + + + + @@ -133,27 +150,10 @@ - - - - - - - - - - - - - - - - - diff --git a/.idea/modules/packages/shulker-proxy-api/shulker.packages.shulker-proxy-api.iml b/.idea/modules/packages/shulker-proxy-api/shulker.packages.shulker-proxy-api.iml index d9bc1356..e24d1180 100644 --- a/.idea/modules/packages/shulker-proxy-api/shulker.packages.shulker-proxy-api.iml +++ b/.idea/modules/packages/shulker-proxy-api/shulker.packages.shulker-proxy-api.iml @@ -1,5 +1,5 @@ - + diff --git a/.idea/modules/packages/shulker-proxy-api/shulker.packages.shulker-proxy-api.main.iml b/.idea/modules/packages/shulker-proxy-api/shulker.packages.shulker-proxy-api.main.iml index ea6f3d7d..19fbfd84 100644 --- a/.idea/modules/packages/shulker-proxy-api/shulker.packages.shulker-proxy-api.main.iml +++ b/.idea/modules/packages/shulker-proxy-api/shulker.packages.shulker-proxy-api.main.iml @@ -1,5 +1,5 @@ - + diff --git a/.idea/modules/packages/shulker-proxy-api/shulker.packages.shulker-proxy-api.test.iml b/.idea/modules/packages/shulker-proxy-api/shulker.packages.shulker-proxy-api.test.iml index 2d801972..0a5a6fe0 100644 --- a/.idea/modules/packages/shulker-proxy-api/shulker.packages.shulker-proxy-api.test.iml +++ b/.idea/modules/packages/shulker-proxy-api/shulker.packages.shulker-proxy-api.test.iml @@ -1,5 +1,5 @@ - + diff --git a/.idea/modules/packages/shulker-sdk/bindings/java/shulker.packages.shulker-sdk-bindings-java.iml b/.idea/modules/packages/shulker-sdk/bindings/java/shulker.packages.shulker-sdk.iml similarity index 55% rename from .idea/modules/packages/shulker-sdk/bindings/java/shulker.packages.shulker-sdk-bindings-java.iml rename to .idea/modules/packages/shulker-sdk/bindings/java/shulker.packages.shulker-sdk.iml index 77130592..50a85829 100644 --- a/.idea/modules/packages/shulker-sdk/bindings/java/shulker.packages.shulker-sdk-bindings-java.iml +++ b/.idea/modules/packages/shulker-sdk/bindings/java/shulker.packages.shulker-sdk.iml @@ -1,5 +1,5 @@ - + diff --git a/.idea/modules/packages/shulker-sdk/bindings/java/shulker.packages.shulker-sdk-bindings-java.main.iml b/.idea/modules/packages/shulker-sdk/bindings/java/shulker.packages.shulker-sdk.main.iml similarity index 88% rename from .idea/modules/packages/shulker-sdk/bindings/java/shulker.packages.shulker-sdk-bindings-java.main.iml rename to .idea/modules/packages/shulker-sdk/bindings/java/shulker.packages.shulker-sdk.main.iml index 11bb4f41..da8697b4 100644 --- a/.idea/modules/packages/shulker-sdk/bindings/java/shulker.packages.shulker-sdk-bindings-java.main.iml +++ b/.idea/modules/packages/shulker-sdk/bindings/java/shulker.packages.shulker-sdk.main.iml @@ -1,7 +1,7 @@ - + - + diff --git a/.idea/modules/packages/shulker-sdk/bindings/java/shulker.packages.shulker-sdk-bindings-java.test.iml b/.idea/modules/packages/shulker-sdk/bindings/java/shulker.packages.shulker-sdk.test.iml similarity index 84% rename from .idea/modules/packages/shulker-sdk/bindings/java/shulker.packages.shulker-sdk-bindings-java.test.iml rename to .idea/modules/packages/shulker-sdk/bindings/java/shulker.packages.shulker-sdk.test.iml index 765c9e83..e5f9f4d5 100644 --- a/.idea/modules/packages/shulker-sdk/bindings/java/shulker.packages.shulker-sdk-bindings-java.test.iml +++ b/.idea/modules/packages/shulker-sdk/bindings/java/shulker.packages.shulker-sdk.test.iml @@ -1,12 +1,12 @@ - + - + - + @@ -31,5 +31,5 @@ - + \ No newline at end of file diff --git a/.idea/modules/packages/shulker-server-agent/shulker.packages.shulker-server-agent.common.iml b/.idea/modules/packages/shulker-server-agent/shulker.packages.shulker-server-agent.common.iml index ceaa37fb..3aee4ba2 100644 --- a/.idea/modules/packages/shulker-server-agent/shulker.packages.shulker-server-agent.common.iml +++ b/.idea/modules/packages/shulker-server-agent/shulker.packages.shulker-server-agent.common.iml @@ -1,5 +1,5 @@ - + @@ -53,7 +53,7 @@ - + diff --git a/.idea/modules/packages/shulker-server-agent/shulker.packages.shulker-server-agent.iml b/.idea/modules/packages/shulker-server-agent/shulker.packages.shulker-server-agent.iml index 8a7c3fdb..974ca10a 100644 --- a/.idea/modules/packages/shulker-server-agent/shulker.packages.shulker-server-agent.iml +++ b/.idea/modules/packages/shulker-server-agent/shulker.packages.shulker-server-agent.iml @@ -1,5 +1,5 @@ - + diff --git a/.idea/modules/packages/shulker-server-agent/shulker.packages.shulker-server-agent.main.iml b/.idea/modules/packages/shulker-server-agent/shulker.packages.shulker-server-agent.main.iml index 9a076031..09e9dc14 100644 --- a/.idea/modules/packages/shulker-server-agent/shulker.packages.shulker-server-agent.main.iml +++ b/.idea/modules/packages/shulker-server-agent/shulker.packages.shulker-server-agent.main.iml @@ -1,5 +1,5 @@ - + diff --git a/.idea/modules/packages/shulker-server-agent/shulker.packages.shulker-server-agent.paper.iml b/.idea/modules/packages/shulker-server-agent/shulker.packages.shulker-server-agent.paper.iml index 05e037de..060bffe4 100644 --- a/.idea/modules/packages/shulker-server-agent/shulker.packages.shulker-server-agent.paper.iml +++ b/.idea/modules/packages/shulker-server-agent/shulker.packages.shulker-server-agent.paper.iml @@ -1,5 +1,5 @@ - + @@ -55,7 +55,7 @@ - + diff --git a/.idea/modules/packages/shulker-server-agent/shulker.packages.shulker-server-agent.test.iml b/.idea/modules/packages/shulker-server-agent/shulker.packages.shulker-server-agent.test.iml index 11fecc26..a2acfb21 100644 --- a/.idea/modules/packages/shulker-server-agent/shulker.packages.shulker-server-agent.test.iml +++ b/.idea/modules/packages/shulker-server-agent/shulker.packages.shulker-server-agent.test.iml @@ -1,5 +1,5 @@ - + diff --git a/.idea/modules/packages/shulker-server-api/shulker.packages.shulker-server-api.iml b/.idea/modules/packages/shulker-server-api/shulker.packages.shulker-server-api.iml index 41309f50..c5911516 100644 --- a/.idea/modules/packages/shulker-server-api/shulker.packages.shulker-server-api.iml +++ b/.idea/modules/packages/shulker-server-api/shulker.packages.shulker-server-api.iml @@ -1,5 +1,5 @@ - + diff --git a/.idea/modules/packages/shulker-server-api/shulker.packages.shulker-server-api.main.iml b/.idea/modules/packages/shulker-server-api/shulker.packages.shulker-server-api.main.iml index b1c84698..69f6a214 100644 --- a/.idea/modules/packages/shulker-server-api/shulker.packages.shulker-server-api.main.iml +++ b/.idea/modules/packages/shulker-server-api/shulker.packages.shulker-server-api.main.iml @@ -1,5 +1,5 @@ - + diff --git a/.idea/modules/packages/shulker-server-api/shulker.packages.shulker-server-api.test.iml b/.idea/modules/packages/shulker-server-api/shulker.packages.shulker-server-api.test.iml index 3086ef51..446dd2bc 100644 --- a/.idea/modules/packages/shulker-server-api/shulker.packages.shulker-server-api.test.iml +++ b/.idea/modules/packages/shulker-server-api/shulker.packages.shulker-server-api.test.iml @@ -1,5 +1,5 @@ - + diff --git a/.idea/modules/packages/shulker.packages.iml b/.idea/modules/packages/shulker.packages.iml index 3f3feecc..3d6fdaac 100644 --- a/.idea/modules/packages/shulker.packages.iml +++ b/.idea/modules/packages/shulker.packages.iml @@ -1,5 +1,5 @@ - + diff --git a/.idea/modules/shulker.iml b/.idea/modules/shulker.iml index 2eb58930..1c056edc 100644 --- a/.idea/modules/shulker.iml +++ b/.idea/modules/shulker.iml @@ -1,5 +1,5 @@ - + diff --git a/.idea/modules/shulker.main.iml b/.idea/modules/shulker.main.iml index c802318a..480d07d5 100644 --- a/.idea/modules/shulker.main.iml +++ b/.idea/modules/shulker.main.iml @@ -1,5 +1,5 @@ - + diff --git a/.idea/modules/shulker.test.iml b/.idea/modules/shulker.test.iml index 2b5fa6f3..78341373 100644 --- a/.idea/modules/shulker.test.iml +++ b/.idea/modules/shulker.test.iml @@ -1,5 +1,5 @@ - + diff --git a/.releaserc.cjs b/.releaserc.cjs index 54843b44..b21b023b 100644 --- a/.releaserc.cjs +++ b/.releaserc.cjs @@ -111,7 +111,7 @@ module.exports = { [ '@semantic-release/exec', { - publishCmd: './gradlew publish', + publishCmd: 'IS_RELEASE=true ./gradlew publish', }, ], [ diff --git a/Cargo.lock b/Cargo.lock index 8b104c4f..96ba0b31 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -575,6 +575,26 @@ dependencies = [ "windows-sys 0.45.0", ] +[[package]] +name = "const_format" +version = "0.2.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3a214c7af3d04997541b18d432afaff4c455e79e2029079647e72fc2bd27673" +dependencies = [ + "const_format_proc_macros", +] + +[[package]] +name = "const_format_proc_macros" +version = "0.2.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7f6ff08fd20f4f299298a28e2dfa8a8ba1036e6cd2460ac1de7b425d76f2500" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + [[package]] name = "convert_case" version = "0.4.0" @@ -2302,6 +2322,7 @@ dependencies = [ "anyhow", "async-trait", "clap", + "const_format", "futures", "google-agones-crds", "google-agones-sdk", @@ -2897,6 +2918,12 @@ dependencies = [ "tinyvec", ] +[[package]] +name = "unicode-xid" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" + [[package]] name = "unsafe-libyaml" version = "0.2.9" diff --git a/Cargo.toml b/Cargo.toml index 011ffe3b..9d18bdad 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,6 +35,7 @@ async-trait = "0.1.74" base64 = "0.21.5" chrono = { version = "0.4.31", features = ["serde"] } clap = { version = "4.4.8", features = ["derive", "env"] } +const_format = "0.2.32" futures = "0.3.29" futures-core = "0.3.29" hostname = "0.3.1" diff --git a/build.gradle.kts b/build.gradle.kts index 1efd7fad..ca7e6a89 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -2,6 +2,7 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar import io.gitlab.arturbosch.detekt.Detekt import io.gitlab.arturbosch.detekt.DetektCreateBaselineTask import io.gitlab.arturbosch.detekt.report.ReportMergeTask +import org.jetbrains.kotlin.utils.addToStdlib.safeAs plugins { id("idea") @@ -10,11 +11,11 @@ plugins { id("jacoco") id("maven-publish") id("signing") - kotlin("jvm") version "1.9.10" - kotlin("kapt") version "1.9.10" - id("org.jlleitschuh.gradle.ktlint") version "11.6.1" - id("com.github.johnrengelman.shadow") version "8.1.0" - id("io.gitlab.arturbosch.detekt") version "1.23.1" + kotlin("jvm") version libs.versions.kotlin.get() + kotlin("kapt") version libs.versions.kotlin.get() + alias(libs.plugins.shadow) + alias(libs.plugins.ktlint) + alias(libs.plugins.detekt) } repositories { @@ -25,9 +26,17 @@ val detektReportMergeSarif by tasks.registering(ReportMergeTask::class) { output = layout.buildDirectory.file("reports/detekt/merge.sarif") } +allprojects { + if (System.getenv("IS_RELEASE") != "true") { + version = "$version-SNAPSHOT" + } +} + subprojects { if (listOf("packages").contains(project.name)) return@subprojects + val libs = rootProject.libs + apply(plugin = "idea") apply(plugin = "java") apply(plugin = "java-library") @@ -69,8 +78,8 @@ subprojects { if (!project.hasProperty("javaOnly")) { apply(plugin = "org.jetbrains.kotlin.jvm") - apply(plugin = "org.jlleitschuh.gradle.ktlint") - apply(plugin = "io.gitlab.arturbosch.detekt") + apply(plugin = libs.plugins.ktlint.get().pluginId) + apply(plugin = libs.plugins.detekt.get().pluginId) dependencies { testImplementation(kotlin("test")) @@ -111,7 +120,7 @@ subprojects { } if (!project.hasProperty("isLibrary")) { - apply(plugin = "com.github.johnrengelman.shadow") + apply(plugin = libs.plugins.shadow.get().pluginId) tasks { assemble { @@ -155,7 +164,7 @@ subprojects { licenses { license { name.set("The Apache License, Version 2.0") - url.set("http://www.apache.org/licenses/LICENSE-2.0.txt") + url.set("https://www.apache.org/licenses/LICENSE-2.0.txt") } } @@ -172,8 +181,15 @@ subprojects { repositories { maven { - name = "Shulker" - url = uri("https://maven.jeremylvln.fr/artifactory/shulker") + name = "shulker" + + url = if ((version as String).endsWith("-SNAPSHOT")) { + uri("https://maven.jeremylvln.fr/artifactory/shulker-snapshots") + } else { + uri("https://maven.jeremylvln.fr/artifactory/shulker-releases") + } + + credentials { username = findProperty("artifactory.username")?.toString() ?: System.getenv("ARTIFACTORY_USERNAME") password = findProperty("artifactory.password")?.toString() ?: System.getenv("ARTIFACTORY_PASSWORD") @@ -227,11 +243,11 @@ subprojects { } dependencies { - "commonCompileOnly"("net.kyori:adventure-api:4.14.0") - "bungeecordCompileOnly"("net.md-5:bungeecord-api:1.20-R0.1") - "bungeecordImplementation"("net.kyori:adventure-platform-bungeecord:4.3.1") - "velocityCompileOnly"("com.velocitypowered:velocity-api:3.1.1") - "kaptVelocity"("com.velocitypowered:velocity-api:3.1.1") + "commonCompileOnly"(libs.adventure.api) + "bungeecordCompileOnly"(libs.bungeecord.api) + "bungeecordImplementation"(libs.adventure.platform.bungeecord) + "velocityCompileOnly"(libs.velocity.api) + "kaptVelocity"(libs.velocity.api) } } else if (project.name == "shulker-server-agent") { val commonSourceSet = sourceSets.create("common") @@ -240,8 +256,8 @@ subprojects { } dependencies { - "commonCompileOnly"("net.kyori:adventure-api:4.14.0") - "paperCompileOnly"("dev.folia:folia-api:1.19.4-R0.1-SNAPSHOT") + "commonCompileOnly"(libs.adventure.api) + "paperCompileOnly"(libs.folia.api) } } } diff --git a/packages/google-agones-sdk/bindings/java/build.gradle.kts b/packages/google-agones-sdk/bindings/java/build.gradle.kts index 31e8c2d1..0b1a6959 100644 --- a/packages/google-agones-sdk/bindings/java/build.gradle.kts +++ b/packages/google-agones-sdk/bindings/java/build.gradle.kts @@ -1,10 +1,10 @@ dependencies { - api("com.google.protobuf:protobuf-java:3.25.0") - implementation("com.google.api.grpc:proto-google-common-protos:2.28.0") - implementation("io.grpc:grpc-protobuf:1.59.0") - implementation("io.grpc:grpc-services:1.59.0") - implementation("io.grpc:grpc-stub:1.59.0") - compileOnly("org.apache.tomcat:annotations-api:6.0.53") + api(libs.protobuf) + implementation(libs.grpc.common.protos) + implementation(libs.grpc.protobuf) + implementation(libs.grpc.services) + implementation(libs.grpc.stub) + compileOnly(libs.annotations.api) } configure { diff --git a/packages/google-open-match-sdk/bindings/java/build.gradle.kts b/packages/google-open-match-sdk/bindings/java/build.gradle.kts index 78f09e08..59267b6f 100644 --- a/packages/google-open-match-sdk/bindings/java/build.gradle.kts +++ b/packages/google-open-match-sdk/bindings/java/build.gradle.kts @@ -1,9 +1,9 @@ dependencies { - api("com.google.protobuf:protobuf-java:3.25.0") - implementation("io.grpc:grpc-protobuf:1.59.0") - implementation("io.grpc:grpc-services:1.59.0") - implementation("io.grpc:grpc-stub:1.59.0") - compileOnly("org.apache.tomcat:annotations-api:6.0.53") + api(libs.protobuf) + implementation(libs.grpc.protobuf) + implementation(libs.grpc.services) + implementation(libs.grpc.stub) + compileOnly(libs.annotations.api) } configure { diff --git a/packages/shulker-operator/Cargo.toml b/packages/shulker-operator/Cargo.toml index b16d31e0..69e885da 100644 --- a/packages/shulker-operator/Cargo.toml +++ b/packages/shulker-operator/Cargo.toml @@ -24,6 +24,7 @@ default = [] anyhow.workspace = true async-trait.workspace = true clap.workspace = true +const_format.workspace = true futures.workspace = true google-agones-crds.workspace = true google-agones-sdk = { workspace = true, features = ["client"] } diff --git a/packages/shulker-operator/src/agent.rs b/packages/shulker-operator/src/agent.rs new file mode 100644 index 00000000..ed5641ea --- /dev/null +++ b/packages/shulker-operator/src/agent.rs @@ -0,0 +1,5 @@ +#[derive(Clone, Debug)] +pub struct AgentConfig { + pub maven_repository: String, + pub version: String, +} diff --git a/packages/shulker-operator/src/constants.rs b/packages/shulker-operator/src/constants.rs new file mode 100644 index 00000000..da29759b --- /dev/null +++ b/packages/shulker-operator/src/constants.rs @@ -0,0 +1,14 @@ +#[cfg(any(test, debug_assertions))] +pub const SHULKER_PLUGIN_REPOSITORY: &str = + "https://maven.jeremylvln.fr/artifactory/shulker-snapshots"; +#[cfg(not(debug_assertions))] +pub const SHULKER_PLUGIN_REPOSITORY: &str = + "https://maven.jeremylvln.fr/artifactory/shulker-releases"; + +#[cfg(test)] +pub const SHULKER_PLUGIN_VERSION: &str = "0.0.0-test-cfg"; +#[cfg(all(not(test), debug_assertions))] +pub const SHULKER_PLUGIN_VERSION: &str = + const_format::concatcp!(env!("CARGO_PKG_VERSION"), "-SNAPSHOT"); +#[cfg(not(debug_assertions))] +pub const SHULKER_PLUGIN_VERSION: &str = env!("CARGO_PKG_VERSION"); diff --git a/packages/shulker-operator/src/lib.rs b/packages/shulker-operator/src/lib.rs index 938ea014..78a58c9d 100644 --- a/packages/shulker-operator/src/lib.rs +++ b/packages/shulker-operator/src/lib.rs @@ -1,4 +1,6 @@ +pub mod agent; pub mod api; +pub mod constants; pub mod reconcilers; pub mod resources; pub mod summon; diff --git a/packages/shulker-operator/src/main.rs b/packages/shulker-operator/src/main.rs index 8cbbbce1..11026c9b 100644 --- a/packages/shulker-operator/src/main.rs +++ b/packages/shulker-operator/src/main.rs @@ -4,8 +4,9 @@ use http::Uri; use kube::Client; use shulker_kube_utils::{lease, metrics}; use shulker_operator::{ + agent::AgentConfig, api::{self, GrpcServerContext}, - reconcilers, + constants, reconcilers, }; use shulker_utils::telemetry; use tonic::transport::{Channel, ClientTlsConfig, Identity}; @@ -51,6 +52,22 @@ struct Args { /// Allocator service #[arg(long, value_name = "path")] agones_allocator_tls_client_key: Option, + + #[arg( + long, + default_value_t = constants::SHULKER_PLUGIN_REPOSITORY.to_string(), + value_name = "url", + env = "SHULKER_AGENT_MAVEN_REPOSITORY" + )] + agent_maven_repository: String, + + #[arg( + long, + default_value_t = constants::SHULKER_PLUGIN_VERSION.to_string(), + value_name = "version", + env = "SHULKER_AGENT_VERSION" + )] + agent_version: String, } #[tokio::main] @@ -92,15 +109,20 @@ async fn main() -> anyhow::Result<()> { let agones_allocator_client = AllocationServiceClient::connect(agones_allocator_channel).await?; + let agent_config = AgentConfig { + maven_repository: args.agent_maven_repository, + version: args.agent_version, + }; + tokio::select! { _ = tokio::signal::ctrl_c() => { cancellation_token.cancel(); }, _ = lease_holder => {}, _ = reconcilers::minecraft_cluster::run(client.clone()) => {}, - _ = reconcilers::proxy_fleet::run(client.clone()) => {}, - _ = reconcilers::minecraft_server::run(client.clone()) => {}, - _ = reconcilers::minecraft_server_fleet::run(client.clone()) => {}, + _ = reconcilers::proxy_fleet::run(client.clone(), agent_config.clone()) => {}, + _ = reconcilers::minecraft_server::run(client.clone(), agent_config.clone()) => {}, + _ = reconcilers::minecraft_server_fleet::run(client.clone(), agent_config.clone()) => {}, _ = metrics::create_http_server(args.metrics_bind_address)? => {}, _ = api::create_grpc_server(args.api_bind_address, GrpcServerContext { client: client.clone(), diff --git a/packages/shulker-operator/src/reconcilers/minecraft_server/gameserver.rs b/packages/shulker-operator/src/reconcilers/minecraft_server/gameserver.rs index 9d433ff7..4351f38d 100644 --- a/packages/shulker-operator/src/reconcilers/minecraft_server/gameserver.rs +++ b/packages/shulker-operator/src/reconcilers/minecraft_server/gameserver.rs @@ -21,6 +21,7 @@ use lazy_static::lazy_static; use shulker_crds::v1alpha1::minecraft_cluster::MinecraftCluster; use shulker_crds::v1alpha1::minecraft_server::MinecraftServerVersion; +use crate::agent::AgentConfig; use crate::resources::resourceref_resolver::ResourceRefResolver; use google_agones_crds::v1::game_server::GameServer; use google_agones_crds::v1::game_server::GameServerEvictionSpec; @@ -38,13 +39,6 @@ const MINECRAFT_SERVER_IMAGE: &str = "itzg/minecraft-server:2023.10.1-java17"; const MINECRAFT_SERVER_SHULKER_CONFIG_DIR: &str = "/mnt/shulker/config"; const MINECRAFT_SERVER_CONFIG_DIR: &str = "/config"; const MINECRAFT_SERVER_DATA_DIR: &str = "/data"; -const MINECRAFT_SERVER_SHULKER_MAVEN_REPOSITORY: &str = - "https://maven.jeremylvln.fr/artifactory/shulker"; - -#[cfg(not(test))] -const MINECRAFT_SERVER_SHULKER_PROXY_AGENT_VERSION: &str = env!("CARGO_PKG_VERSION"); -#[cfg(test)] -const MINECRAFT_SERVER_SHULKER_PROXY_AGENT_VERSION: &str = "0.0.0-test-cfg"; lazy_static! { static ref PROXY_SECURITY_CONTEXT: SecurityContext = SecurityContext { @@ -68,6 +62,7 @@ pub struct GameServerBuilder { #[derive(Clone, Debug)] pub struct GameServerBuilderContext<'a> { pub cluster: &'a MinecraftCluster, + pub agent_config: &'a AgentConfig, } #[async_trait::async_trait] @@ -107,7 +102,7 @@ impl<'a> ResourceBuilder<'a> for GameServerBuilder { }, spec: Self::get_game_server_spec( &self.resourceref_resolver, - context.unwrap().cluster, + context.as_ref().unwrap(), minecraft_server, ) .await?, @@ -118,7 +113,7 @@ impl<'a> ResourceBuilder<'a> for GameServerBuilder { } } -impl GameServerBuilder { +impl<'a> GameServerBuilder { pub fn new(client: Client) -> Self { GameServerBuilder { client: client.clone(), @@ -128,11 +123,11 @@ impl GameServerBuilder { pub async fn get_game_server_spec( resourceref_resolver: &ResourceRefResolver, - cluster: &MinecraftCluster, + context: &GameServerBuilderContext<'a>, minecraft_server: &MinecraftServer, ) -> Result { let pod_template_spec = - Self::get_pod_template_spec(resourceref_resolver, cluster, minecraft_server).await?; + Self::get_pod_template_spec(resourceref_resolver, context, minecraft_server).await?; let game_server_spec = GameServerSpec { ports: Some(vec![GameServerPortSpec { @@ -157,7 +152,7 @@ impl GameServerBuilder { async fn get_pod_template_spec( resourceref_resolver: &ResourceRefResolver, - cluster: &MinecraftCluster, + context: &GameServerBuilderContext<'a>, minecraft_server: &MinecraftServer, ) -> Result { let mut pod_spec = PodSpec { @@ -168,7 +163,9 @@ impl GameServerBuilder { "sh".to_string(), format!("{}/init-fs.sh", MINECRAFT_SERVER_SHULKER_CONFIG_DIR), ]), - env: Some(Self::get_init_env(resourceref_resolver, minecraft_server).await?), + env: Some( + Self::get_init_env(resourceref_resolver, context, minecraft_server).await?, + ), security_context: Some(PROXY_SECURITY_CONTEXT.clone()), volume_mounts: Some(vec![ VolumeMount { @@ -188,7 +185,7 @@ impl GameServerBuilder { containers: vec![Container { image: Some(MINECRAFT_SERVER_IMAGE.to_string()), name: "minecraft-server".to_string(), - env: Some(Self::get_env(cluster, &minecraft_server.spec)), + env: Some(Self::get_env(context, &minecraft_server.spec)), image_pull_policy: Some("IfNotPresent".to_string()), security_context: Some(PROXY_SECURITY_CONTEXT.clone()), volume_mounts: Some(vec![ @@ -301,6 +298,7 @@ impl GameServerBuilder { async fn get_init_env( resourceref_resolver: &ResourceRefResolver, + context: &GameServerBuilderContext<'a>, minecraft_server: &MinecraftServer, ) -> Result, anyhow::Error> { let spec = &minecraft_server.spec; @@ -327,13 +325,13 @@ impl GameServerBuilder { ..EnvVar::default() }, EnvVar { - name: "SHULKER_SERVER_AGENT_VERSION".to_string(), - value: Some(MINECRAFT_SERVER_SHULKER_PROXY_AGENT_VERSION.to_string()), + name: "SHULKER_MAVEN_REPOSITORY".to_string(), + value: Some(context.agent_config.maven_repository.clone()), ..EnvVar::default() }, EnvVar { - name: "SHULKER_MAVEN_REPOSITORY".to_string(), - value: Some(MINECRAFT_SERVER_SHULKER_MAVEN_REPOSITORY.to_string()), + name: "SHULKER_SERVER_AGENT_VERSION".to_string(), + value: Some(context.agent_config.version.clone()), ..EnvVar::default() }, ]; @@ -384,7 +382,7 @@ impl GameServerBuilder { Ok(env) } - fn get_env(cluster: &MinecraftCluster, spec: &MinecraftServerSpec) -> Vec { + fn get_env(context: &GameServerBuilderContext, spec: &MinecraftServerSpec) -> Vec { let mut env: Vec = vec![ EnvVar { name: "SHULKER_SERVER_NAME".to_string(), @@ -411,7 +409,8 @@ impl GameServerBuilder { EnvVar { name: "SHULKER_NETWORK_ADMINS".to_string(), value: Some( - cluster + context + .cluster .spec .network_admins .as_ref() @@ -511,6 +510,8 @@ mod tests { use shulker_kube_utils::reconcilers::builder::ResourceBuilder; use crate::{ + agent::AgentConfig, + constants, reconcilers::{ minecraft_cluster::fixtures::TEST_CLUSTER, minecraft_server::fixtures::{create_client_mock, TEST_SERVER}, @@ -535,6 +536,10 @@ mod tests { let name = super::GameServerBuilder::name(&TEST_SERVER); let context = super::GameServerBuilderContext { cluster: &TEST_CLUSTER, + agent_config: &AgentConfig { + maven_repository: constants::SHULKER_PLUGIN_REPOSITORY.to_string(), + version: constants::SHULKER_PLUGIN_VERSION.to_string(), + }, }; // W @@ -552,11 +557,19 @@ mod tests { // G let client = create_client_mock(); let resourceref_resolver = ResourceRefResolver::new(client); + let context = super::GameServerBuilderContext { + cluster: &TEST_CLUSTER, + agent_config: &AgentConfig { + maven_repository: constants::SHULKER_PLUGIN_REPOSITORY.to_string(), + version: constants::SHULKER_PLUGIN_VERSION.to_string(), + }, + }; // W - let env = super::GameServerBuilder::get_init_env(&resourceref_resolver, &TEST_SERVER) - .await - .unwrap(); + let env = + super::GameServerBuilder::get_init_env(&resourceref_resolver, &context, &TEST_SERVER) + .await + .unwrap(); // T let world_env = env @@ -578,11 +591,19 @@ mod tests { // G let client = create_client_mock(); let resourceref_resolver = ResourceRefResolver::new(client); + let context = super::GameServerBuilderContext { + cluster: &TEST_CLUSTER, + agent_config: &AgentConfig { + maven_repository: constants::SHULKER_PLUGIN_REPOSITORY.to_string(), + version: constants::SHULKER_PLUGIN_VERSION.to_string(), + }, + }; // W - let env = super::GameServerBuilder::get_init_env(&resourceref_resolver, &TEST_SERVER) - .await - .unwrap(); + let env = + super::GameServerBuilder::get_init_env(&resourceref_resolver, &context, &TEST_SERVER) + .await + .unwrap(); // T let plugins_env = env @@ -604,11 +625,19 @@ mod tests { // G let client = create_client_mock(); let resourceref_resolver = ResourceRefResolver::new(client); + let context = super::GameServerBuilderContext { + cluster: &TEST_CLUSTER, + agent_config: &AgentConfig { + maven_repository: constants::SHULKER_PLUGIN_REPOSITORY.to_string(), + version: constants::SHULKER_PLUGIN_VERSION.to_string(), + }, + }; // W - let env = super::GameServerBuilder::get_init_env(&resourceref_resolver, &TEST_SERVER) - .await - .unwrap(); + let env = + super::GameServerBuilder::get_init_env(&resourceref_resolver, &context, &TEST_SERVER) + .await + .unwrap(); // T let patches_env = env @@ -629,9 +658,16 @@ mod tests { fn get_env_merges_env_overrides() { // G let spec = TEST_SERVER.spec.clone(); + let context = super::GameServerBuilderContext { + cluster: &TEST_CLUSTER, + agent_config: &AgentConfig { + maven_repository: constants::SHULKER_PLUGIN_REPOSITORY.to_string(), + version: constants::SHULKER_PLUGIN_VERSION.to_string(), + }, + }; // W - let env = super::GameServerBuilder::get_env(&TEST_CLUSTER, &spec); + let env = super::GameServerBuilder::get_env(&context, &spec); // T spec.pod_overrides diff --git a/packages/shulker-operator/src/reconcilers/minecraft_server/mod.rs b/packages/shulker-operator/src/reconcilers/minecraft_server/mod.rs index 48885dc0..784e8930 100644 --- a/packages/shulker-operator/src/reconcilers/minecraft_server/mod.rs +++ b/packages/shulker-operator/src/reconcilers/minecraft_server/mod.rs @@ -16,6 +16,8 @@ use shulker_crds::{ v1alpha1::minecraft_server::{MinecraftServer, MinecraftServerStatus}, }; +use crate::agent::AgentConfig; + use self::{ config_map::ConfigMapBuilder, gameserver::{GameServerBuilder, GameServerBuilderContext}, @@ -31,6 +33,7 @@ mod fixtures; struct MinecraftServerReconciler { client: kube::Client, + agent_config: AgentConfig, // Builders config_map_builder: ConfigMapBuilder, @@ -56,7 +59,10 @@ impl MinecraftServerReconciler { let gameserver = reconcile_builder( &self.gameserver_builder, minecraft_server.as_ref(), - Some(GameServerBuilderContext { cluster: &cluster }), + Some(GameServerBuilderContext { + cluster: &cluster, + agent_config: &self.agent_config, + }), ) .await .map_err(ReconcilerError::BuilderError)?; @@ -180,7 +186,7 @@ fn error_policy( Action::requeue(Duration::from_secs(5)) } -pub async fn run(client: Client) { +pub async fn run(client: Client, agent_config: AgentConfig) { let minecraft_servers_api = Api::::all(client.clone()); if let Err(e) = minecraft_servers_api .list(&ListParams::default().limit(1)) @@ -192,6 +198,7 @@ pub async fn run(client: Client) { let context = MinecraftServerReconciler { client: client.clone(), + agent_config, config_map_builder: ConfigMapBuilder::new(client.clone()), gameserver_builder: GameServerBuilder::new(client.clone()), }; diff --git a/packages/shulker-operator/src/reconcilers/minecraft_server/snapshots/shulker_operator__reconcilers__minecraft_server__gameserver__tests__build_snapshot.snap b/packages/shulker-operator/src/reconcilers/minecraft_server/snapshots/shulker_operator__reconcilers__minecraft_server__gameserver__tests__build_snapshot.snap index e4b182d4..04bcfb38 100644 --- a/packages/shulker-operator/src/reconcilers/minecraft_server/snapshots/shulker_operator__reconcilers__minecraft_server__gameserver__tests__build_snapshot.snap +++ b/packages/shulker-operator/src/reconcilers/minecraft_server/snapshots/shulker_operator__reconcilers__minecraft_server__gameserver__tests__build_snapshot.snap @@ -107,10 +107,10 @@ spec: value: /data - name: TYPE value: PAPER + - name: SHULKER_MAVEN_REPOSITORY + value: "https://maven.jeremylvln.fr/artifactory/shulker-snapshots" - name: SHULKER_SERVER_AGENT_VERSION value: 0.0.0-test-cfg - - name: SHULKER_MAVEN_REPOSITORY - value: "https://maven.jeremylvln.fr/artifactory/shulker" - name: SERVER_WORLD_URL value: "https://example.com/my_world.tar.gz" - name: SERVER_PLUGIN_URLS diff --git a/packages/shulker-operator/src/reconcilers/minecraft_server_fleet/fleet.rs b/packages/shulker-operator/src/reconcilers/minecraft_server_fleet/fleet.rs index 6569879c..dee485cb 100644 --- a/packages/shulker-operator/src/reconcilers/minecraft_server_fleet/fleet.rs +++ b/packages/shulker-operator/src/reconcilers/minecraft_server_fleet/fleet.rs @@ -8,6 +8,8 @@ use kube::Client; use kube::ResourceExt; use shulker_crds::v1alpha1::minecraft_cluster::MinecraftCluster; +use crate::agent::AgentConfig; +use crate::reconcilers::minecraft_server::gameserver::GameServerBuilderContext; use crate::resources::resourceref_resolver::ResourceRefResolver; use google_agones_crds::v1::fleet::Fleet; use google_agones_crds::v1::fleet::FleetSpec; @@ -27,6 +29,7 @@ pub struct FleetBuilder { #[derive(Clone, Debug)] pub struct FleetBuilderContext<'a> { pub cluster: &'a MinecraftCluster, + pub agent_config: &'a AgentConfig, } #[async_trait::async_trait] @@ -95,9 +98,14 @@ impl<'a> ResourceBuilder<'a> for FleetBuilder { status: None, }; + let game_server_context = GameServerBuilderContext { + cluster: context.as_ref().unwrap().cluster, + agent_config: context.as_ref().unwrap().agent_config, + }; + let game_server_spec = crate::reconcilers::minecraft_server::gameserver::GameServerBuilder::get_game_server_spec( &self.resourceref_resolver, - context.unwrap().cluster, + &game_server_context, &fake_mincraft_server, ).await?; let replicas = match &minecraft_server_fleet.spec.autoscaling { @@ -152,9 +160,13 @@ impl FleetBuilder { mod tests { use shulker_kube_utils::reconcilers::builder::ResourceBuilder; - use crate::reconcilers::{ - minecraft_cluster::fixtures::TEST_CLUSTER, - minecraft_server_fleet::fixtures::{create_client_mock, TEST_SERVER_FLEET}, + use crate::{ + agent::AgentConfig, + constants, + reconcilers::{ + minecraft_cluster::fixtures::TEST_CLUSTER, + minecraft_server_fleet::fixtures::{create_client_mock, TEST_SERVER_FLEET}, + }, }; #[test] @@ -174,6 +186,10 @@ mod tests { let name = super::FleetBuilder::name(&TEST_SERVER_FLEET); let context = super::FleetBuilderContext { cluster: &TEST_CLUSTER, + agent_config: &AgentConfig { + maven_repository: constants::SHULKER_PLUGIN_REPOSITORY.to_string(), + version: constants::SHULKER_PLUGIN_VERSION.to_string(), + }, }; // W @@ -194,6 +210,10 @@ mod tests { let name = super::FleetBuilder::name(&TEST_SERVER_FLEET); let context = super::FleetBuilderContext { cluster: &TEST_CLUSTER, + agent_config: &AgentConfig { + maven_repository: constants::SHULKER_PLUGIN_REPOSITORY.to_string(), + version: constants::SHULKER_PLUGIN_VERSION.to_string(), + }, }; // W @@ -238,6 +258,10 @@ mod tests { let name = super::FleetBuilder::name(&TEST_SERVER_FLEET); let context = super::FleetBuilderContext { cluster: &TEST_CLUSTER, + agent_config: &AgentConfig { + maven_repository: constants::SHULKER_PLUGIN_REPOSITORY.to_string(), + version: constants::SHULKER_PLUGIN_VERSION.to_string(), + }, }; // W @@ -282,6 +306,10 @@ mod tests { let name = super::FleetBuilder::name(&TEST_SERVER_FLEET); let context = super::FleetBuilderContext { cluster: &TEST_CLUSTER, + agent_config: &AgentConfig { + maven_repository: constants::SHULKER_PLUGIN_REPOSITORY.to_string(), + version: constants::SHULKER_PLUGIN_VERSION.to_string(), + }, }; // W diff --git a/packages/shulker-operator/src/reconcilers/minecraft_server_fleet/mod.rs b/packages/shulker-operator/src/reconcilers/minecraft_server_fleet/mod.rs index 94ee63e0..82aa20e4 100644 --- a/packages/shulker-operator/src/reconcilers/minecraft_server_fleet/mod.rs +++ b/packages/shulker-operator/src/reconcilers/minecraft_server_fleet/mod.rs @@ -16,6 +16,8 @@ use shulker_crds::{ v1alpha1::minecraft_server_fleet::{MinecraftServerFleet, MinecraftServerFleetStatus}, }; +use crate::agent::AgentConfig; + use self::{ config_map::ConfigMapBuilder, fleet::{FleetBuilder, FleetBuilderContext}, @@ -33,6 +35,7 @@ mod fixtures; struct MinecraftServerFleetReconciler { client: kube::Client, + agent_config: AgentConfig, // Builders config_map_builder: ConfigMapBuilder, @@ -63,7 +66,10 @@ impl MinecraftServerFleetReconciler { let fleet = reconcile_builder( &self.fleet_builder, minecraft_server_fleet.as_ref(), - Some(FleetBuilderContext { cluster: &cluster }), + Some(FleetBuilderContext { + cluster: &cluster, + agent_config: &self.agent_config, + }), ) .await .map_err(ReconcilerError::BuilderError)?; @@ -198,7 +204,7 @@ fn error_policy( Action::requeue(Duration::from_secs(5)) } -pub async fn run(client: Client) { +pub async fn run(client: Client, agent_config: AgentConfig) { let minecraft_server_fleets_api = Api::::all(client.clone()); if let Err(e) = minecraft_server_fleets_api .list(&ListParams::default().limit(1)) @@ -210,6 +216,7 @@ pub async fn run(client: Client) { let context = MinecraftServerFleetReconciler { client: client.clone(), + agent_config, config_map_builder: ConfigMapBuilder::new(client.clone()), fleet_builder: FleetBuilder::new(client.clone()), fleet_autoscaler_builder: FleetAutoscalerBuilder::new(client.clone()), diff --git a/packages/shulker-operator/src/reconcilers/minecraft_server_fleet/snapshots/shulker_operator__reconcilers__minecraft_server_fleet__fleet__tests__build_snapshot.snap b/packages/shulker-operator/src/reconcilers/minecraft_server_fleet/snapshots/shulker_operator__reconcilers__minecraft_server_fleet__fleet__tests__build_snapshot.snap index ba7a27b2..6adf19df 100644 --- a/packages/shulker-operator/src/reconcilers/minecraft_server_fleet/snapshots/shulker_operator__reconcilers__minecraft_server_fleet__fleet__tests__build_snapshot.snap +++ b/packages/shulker-operator/src/reconcilers/minecraft_server_fleet/snapshots/shulker_operator__reconcilers__minecraft_server_fleet__fleet__tests__build_snapshot.snap @@ -129,10 +129,10 @@ spec: value: /data - name: TYPE value: PAPER + - name: SHULKER_MAVEN_REPOSITORY + value: "https://maven.jeremylvln.fr/artifactory/shulker-snapshots" - name: SHULKER_SERVER_AGENT_VERSION value: 0.0.0-test-cfg - - name: SHULKER_MAVEN_REPOSITORY - value: "https://maven.jeremylvln.fr/artifactory/shulker" - name: SERVER_WORLD_URL value: "https://example.com/my_world.tar.gz" - name: SERVER_PLUGIN_URLS diff --git a/packages/shulker-operator/src/reconcilers/proxy_fleet/fleet.rs b/packages/shulker-operator/src/reconcilers/proxy_fleet/fleet.rs index 6bd8a7f7..99c1b56e 100644 --- a/packages/shulker-operator/src/reconcilers/proxy_fleet/fleet.rs +++ b/packages/shulker-operator/src/reconcilers/proxy_fleet/fleet.rs @@ -29,6 +29,7 @@ use lazy_static::lazy_static; use shulker_crds::v1alpha1::minecraft_cluster::MinecraftCluster; use shulker_crds::v1alpha1::proxy_fleet::ProxyFleetTemplateVersion; +use crate::agent::AgentConfig; use crate::reconcilers::redis_ref::RedisRef; use crate::resources::resourceref_resolver::ResourceRefResolver; use google_agones_crds::v1::fleet::Fleet; @@ -48,12 +49,6 @@ const PROXY_SHULKER_CONFIG_DIR: &str = "/mnt/shulker/config"; const PROXY_SHULKER_FORWARDING_SECRET_DIR: &str = "/mnt/shulker/forwarding-secret"; const PROXY_DATA_DIR: &str = "/server"; const PROXY_DRAIN_LOCK_DIR: &str = "/mnt/drain-lock"; -const PROXY_SHULKER_MAVEN_REPOSITORY: &str = "https://maven.jeremylvln.fr/artifactory/shulker"; - -#[cfg(not(test))] -const PROXY_SHULKER_PROXY_AGENT_VERSION: &str = env!("CARGO_PKG_VERSION"); -#[cfg(test)] -const PROXY_SHULKER_PROXY_AGENT_VERSION: &str = "0.0.0-test-cfg"; lazy_static! { static ref PROXY_SECURITY_CONTEXT: SecurityContext = SecurityContext { @@ -77,6 +72,7 @@ pub struct FleetBuilder { #[derive(Clone, Debug)] pub struct FleetBuilderContext<'a> { pub cluster: &'a MinecraftCluster, + pub agent_config: &'a AgentConfig, } #[async_trait::async_trait] @@ -104,7 +100,7 @@ impl<'a> ResourceBuilder<'a> for FleetBuilder { context: Option>, ) -> Result { let game_server_spec = self - .get_game_server_spec(context.unwrap().cluster, proxy_fleet) + .get_game_server_spec(context.as_ref().unwrap(), proxy_fleet) .await?; let replicas = match &proxy_fleet.spec.autoscaling { Some(_) => 0, @@ -144,7 +140,7 @@ impl<'a> ResourceBuilder<'a> for FleetBuilder { } } -impl FleetBuilder { +impl<'a> FleetBuilder { pub fn new(client: Client) -> Self { FleetBuilder { client: client.clone(), @@ -154,10 +150,10 @@ impl FleetBuilder { async fn get_game_server_spec( &self, - cluster: &MinecraftCluster, + context: &FleetBuilderContext<'a>, proxy_fleet: &ProxyFleet, ) -> Result { - let pod_template_spec = self.get_pod_template_spec(cluster, proxy_fleet).await?; + let pod_template_spec = self.get_pod_template_spec(context, proxy_fleet).await?; let game_server_spec = GameServerSpec { ports: Some(vec![]), eviction: Some(GameServerEvictionSpec { @@ -177,7 +173,7 @@ impl FleetBuilder { async fn get_pod_template_spec( &self, - cluster: &MinecraftCluster, + context: &FleetBuilderContext<'a>, proxy_fleet: &ProxyFleet, ) -> Result { let mut pod_spec = PodSpec { @@ -188,7 +184,7 @@ impl FleetBuilder { "sh".to_string(), format!("{}/init-fs.sh", PROXY_SHULKER_CONFIG_DIR), ]), - env: Some(self.get_init_env(proxy_fleet).await?), + env: Some(self.get_init_env(context, proxy_fleet).await?), security_context: Some(PROXY_SECURITY_CONTEXT.clone()), volume_mounts: Some(vec![ VolumeMount { @@ -213,7 +209,7 @@ impl FleetBuilder { container_port: 25577, ..ContainerPort::default() }]), - env: Some(self.get_env(cluster, &proxy_fleet.spec.template.spec)?), + env: Some(self.get_env(context, &proxy_fleet.spec.template.spec)?), readiness_probe: Some(Probe { exec: Some(ExecAction { command: Some(vec![ @@ -351,7 +347,11 @@ impl FleetBuilder { }) } - async fn get_init_env(&self, proxy_fleet: &ProxyFleet) -> Result, anyhow::Error> { + async fn get_init_env( + &self, + context: &FleetBuilderContext<'a>, + proxy_fleet: &ProxyFleet, + ) -> Result, anyhow::Error> { let spec = &proxy_fleet.spec.template.spec; let mut env: Vec = vec![ @@ -371,13 +371,13 @@ impl FleetBuilder { ..EnvVar::default() }, EnvVar { - name: "SHULKER_PROXY_AGENT_VERSION".to_string(), - value: Some(PROXY_SHULKER_PROXY_AGENT_VERSION.to_string()), + name: "SHULKER_MAVEN_REPOSITORY".to_string(), + value: Some(context.agent_config.maven_repository.clone()), ..EnvVar::default() }, EnvVar { - name: "SHULKER_MAVEN_REPOSITORY".to_string(), - value: Some(PROXY_SHULKER_MAVEN_REPOSITORY.to_string()), + name: "SHULKER_PROXY_AGENT_VERSION".to_string(), + value: Some(context.agent_config.version.clone()), ..EnvVar::default() }, ]; @@ -419,10 +419,10 @@ impl FleetBuilder { fn get_env( &self, - cluster: &MinecraftCluster, + context: &FleetBuilderContext<'a>, spec: &ProxyFleetTemplateSpec, ) -> Result, anyhow::Error> { - let redis_ref = RedisRef::from_cluster(cluster)?; + let redis_ref = RedisRef::from_cluster(context.cluster)?; let mut env: Vec = vec![ EnvVar { @@ -455,7 +455,8 @@ impl FleetBuilder { EnvVar { name: "SHULKER_NETWORK_ADMINS".to_string(), value: Some( - cluster + context + .cluster .spec .network_admins .as_ref() @@ -552,9 +553,13 @@ mod tests { use k8s_openapi::api::core::v1::EnvVar; use shulker_kube_utils::reconcilers::builder::ResourceBuilder; - use crate::reconcilers::{ - minecraft_cluster::fixtures::TEST_CLUSTER, - proxy_fleet::fixtures::{create_client_mock, TEST_PROXY_FLEET}, + use crate::{ + agent::AgentConfig, + constants, + reconcilers::{ + minecraft_cluster::fixtures::TEST_CLUSTER, + proxy_fleet::fixtures::{create_client_mock, TEST_PROXY_FLEET}, + }, }; #[test] @@ -574,6 +579,10 @@ mod tests { let name = super::FleetBuilder::name(&TEST_PROXY_FLEET); let context = super::FleetBuilderContext { cluster: &TEST_CLUSTER, + agent_config: &AgentConfig { + maven_repository: constants::SHULKER_PLUGIN_REPOSITORY.to_string(), + version: constants::SHULKER_PLUGIN_VERSION.to_string(), + }, }; // W @@ -594,6 +603,10 @@ mod tests { let name = super::FleetBuilder::name(&TEST_PROXY_FLEET); let context = super::FleetBuilderContext { cluster: &TEST_CLUSTER, + agent_config: &AgentConfig { + maven_repository: constants::SHULKER_PLUGIN_REPOSITORY.to_string(), + version: constants::SHULKER_PLUGIN_VERSION.to_string(), + }, }; // W @@ -638,6 +651,10 @@ mod tests { let name = super::FleetBuilder::name(&TEST_PROXY_FLEET); let context = super::FleetBuilderContext { cluster: &TEST_CLUSTER, + agent_config: &AgentConfig { + maven_repository: constants::SHULKER_PLUGIN_REPOSITORY.to_string(), + version: constants::SHULKER_PLUGIN_VERSION.to_string(), + }, }; // W @@ -679,9 +696,19 @@ mod tests { // G let client = create_client_mock(); let builder = super::FleetBuilder::new(client); + let context = super::FleetBuilderContext { + cluster: &TEST_CLUSTER, + agent_config: &AgentConfig { + maven_repository: constants::SHULKER_PLUGIN_REPOSITORY.to_string(), + version: constants::SHULKER_PLUGIN_VERSION.to_string(), + }, + }; // W - let env = builder.get_init_env(&TEST_PROXY_FLEET).await.unwrap(); + let env = builder + .get_init_env(&context, &TEST_PROXY_FLEET) + .await + .unwrap(); // T let plugins_env = env @@ -703,9 +730,19 @@ mod tests { // G let client = create_client_mock(); let builder = super::FleetBuilder::new(client); + let context = super::FleetBuilderContext { + cluster: &TEST_CLUSTER, + agent_config: &AgentConfig { + maven_repository: constants::SHULKER_PLUGIN_REPOSITORY.to_string(), + version: constants::SHULKER_PLUGIN_VERSION.to_string(), + }, + }; // W - let env = builder.get_init_env(&TEST_PROXY_FLEET).await.unwrap(); + let env = builder + .get_init_env(&context, &TEST_PROXY_FLEET) + .await + .unwrap(); // T let patches_env = env @@ -728,9 +765,16 @@ mod tests { let client = create_client_mock(); let builder = super::FleetBuilder::new(client); let spec = TEST_PROXY_FLEET.spec.clone(); + let context = super::FleetBuilderContext { + cluster: &TEST_CLUSTER, + agent_config: &AgentConfig { + maven_repository: constants::SHULKER_PLUGIN_REPOSITORY.to_string(), + version: constants::SHULKER_PLUGIN_VERSION.to_string(), + }, + }; // W - let env = builder.get_env(&TEST_CLUSTER, &spec.template.spec).unwrap(); + let env = builder.get_env(&context, &spec.template.spec).unwrap(); // T spec.template diff --git a/packages/shulker-operator/src/reconcilers/proxy_fleet/mod.rs b/packages/shulker-operator/src/reconcilers/proxy_fleet/mod.rs index f42a6e58..e4743c1e 100644 --- a/packages/shulker-operator/src/reconcilers/proxy_fleet/mod.rs +++ b/packages/shulker-operator/src/reconcilers/proxy_fleet/mod.rs @@ -16,6 +16,8 @@ use shulker_crds::{ v1alpha1::proxy_fleet::{ProxyFleet, ProxyFleetStatus}, }; +use crate::agent::AgentConfig; + use self::{ config_map::ConfigMapBuilder, fleet::{FleetBuilder, FleetBuilderContext}, @@ -35,6 +37,7 @@ mod fixtures; struct ProxyFleetReconciler { client: kube::Client, + agent_config: AgentConfig, // Builders config_map_builder: ConfigMapBuilder, @@ -65,7 +68,10 @@ impl ProxyFleetReconciler { let fleet = reconcile_builder( &self.fleet_builder, proxy_fleet.as_ref(), - Some(FleetBuilderContext { cluster: &cluster }), + Some(FleetBuilderContext { + cluster: &cluster, + agent_config: &self.agent_config, + }), ) .await .map_err(ReconcilerError::BuilderError)?; @@ -186,7 +192,7 @@ fn error_policy( Action::requeue(Duration::from_secs(5)) } -pub async fn run(client: Client) { +pub async fn run(client: Client, agent_config: AgentConfig) { let proxy_fleets_api = Api::::all(client.clone()); if let Err(e) = proxy_fleets_api.list(&ListParams::default().limit(1)).await { error!("CRD is not queryable; {e:?}. Is the CRD installed?"); @@ -195,6 +201,7 @@ pub async fn run(client: Client) { let context = ProxyFleetReconciler { client: client.clone(), + agent_config, config_map_builder: ConfigMapBuilder::new(client.clone()), service_builder: ServiceBuilder::new(client.clone()), fleet_builder: FleetBuilder::new(client.clone()), diff --git a/packages/shulker-operator/src/reconcilers/proxy_fleet/snapshots/shulker_operator__reconcilers__proxy_fleet__fleet__tests__build_snapshot.snap b/packages/shulker-operator/src/reconcilers/proxy_fleet/snapshots/shulker_operator__reconcilers__proxy_fleet__fleet__tests__build_snapshot.snap index 3c01cb84..ca74b191 100644 --- a/packages/shulker-operator/src/reconcilers/proxy_fleet/snapshots/shulker_operator__reconcilers__proxy_fleet__fleet__tests__build_snapshot.snap +++ b/packages/shulker-operator/src/reconcilers/proxy_fleet/snapshots/shulker_operator__reconcilers__proxy_fleet__fleet__tests__build_snapshot.snap @@ -128,10 +128,10 @@ spec: value: /server - name: TYPE value: VELOCITY + - name: SHULKER_MAVEN_REPOSITORY + value: "https://maven.jeremylvln.fr/artifactory/shulker-snapshots" - name: SHULKER_PROXY_AGENT_VERSION value: 0.0.0-test-cfg - - name: SHULKER_MAVEN_REPOSITORY - value: "https://maven.jeremylvln.fr/artifactory/shulker" - name: PROXY_PLUGIN_URLS value: "https://example.com/my_plugin.jar" - name: PROXY_PATCH_URLS diff --git a/packages/shulker-proxy-agent/build.gradle.kts b/packages/shulker-proxy-agent/build.gradle.kts index c0e912cd..89683464 100644 --- a/packages/shulker-proxy-agent/build.gradle.kts +++ b/packages/shulker-proxy-agent/build.gradle.kts @@ -1,24 +1,24 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar plugins { - id("com.github.gmazzo.buildconfig") version "4.1.2" + alias(libs.plugins.buildconfig) } dependencies { - "commonApi"(project(":packages:shulker-proxy-api")) + commonApi(project(":packages:shulker-proxy-api")) // Kubernetes - "commonCompileOnly"("io.fabric8:kubernetes-client-api:6.9.2") - "commonRuntimeOnly"("io.fabric8:kubernetes-client:6.9.2") - "commonImplementation"("io.fabric8:kubernetes-httpclient-okhttp:6.9.2") + commonCompileOnly(libs.kubernetes.client) + commonRuntimeOnly(libs.kubernetes.client.api) + commonImplementation(libs.kubernetes.client.http) // Agones - "commonImplementation"(project(":packages:google-agones-sdk-bindings-java")) - "commonRuntimeOnly"("io.grpc:grpc-netty-shaded:1.59.0") + commonImplementation(project(":packages:google-agones-sdk")) + commonRuntimeOnly(libs.netty.shaded) // Sync - "commonImplementation"("redis.clients:jedis:5.0.2") - "commonImplementation"("com.google.guava:guava:32.1.3-jre") + commonImplementation(libs.jedis) + commonImplementation(libs.guava) } setOf("bungeecordJar", "velocityJar").forEach { taskName -> diff --git a/packages/shulker-sdk/bindings/java/build.gradle.kts b/packages/shulker-sdk/bindings/java/build.gradle.kts index 78f09e08..59267b6f 100644 --- a/packages/shulker-sdk/bindings/java/build.gradle.kts +++ b/packages/shulker-sdk/bindings/java/build.gradle.kts @@ -1,9 +1,9 @@ dependencies { - api("com.google.protobuf:protobuf-java:3.25.0") - implementation("io.grpc:grpc-protobuf:1.59.0") - implementation("io.grpc:grpc-services:1.59.0") - implementation("io.grpc:grpc-stub:1.59.0") - compileOnly("org.apache.tomcat:annotations-api:6.0.53") + api(libs.protobuf) + implementation(libs.grpc.protobuf) + implementation(libs.grpc.services) + implementation(libs.grpc.stub) + compileOnly(libs.annotations.api) } configure { diff --git a/packages/shulker-server-agent/build.gradle.kts b/packages/shulker-server-agent/build.gradle.kts index 76c65ed1..23827a57 100644 --- a/packages/shulker-server-agent/build.gradle.kts +++ b/packages/shulker-server-agent/build.gradle.kts @@ -1,11 +1,11 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar dependencies { - "commonApi"(project(":packages:shulker-server-api")) + commonApi(project(":packages:shulker-server-api")) // Agones - "commonImplementation"(project(":packages:google-agones-sdk-bindings-java")) - "commonRuntimeOnly"("io.grpc:grpc-netty-shaded:1.59.0") + commonImplementation(project(":packages:google-agones-sdk")) + commonRuntimeOnly(libs.netty.shaded) } setOf("paperJar").forEach { taskName -> diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index 9a845684..00000000 --- a/settings.gradle +++ /dev/null @@ -1,16 +0,0 @@ -rootProject.name = "shulker" - -def includeBindingProject(String name) { - include ":packages:${name}-bindings-java" - project(":packages:${name}-bindings-java").projectDir = file("packages/${name}/bindings/java") -} - -includeBindingProject('google-agones-sdk') -includeBindingProject('google-open-match-sdk') -includeBindingProject('shulker-sdk') - -include ':packages:shulker-proxy-api' -include ':packages:shulker-proxy-agent' - -include ':packages:shulker-server-api' -include ':packages:shulker-server-agent' diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 00000000..9a9cf39b --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,49 @@ +rootProject.name = "shulker" + +dependencyResolutionManagement { + versionCatalogs { + create("libs") { + version("kotlin", "1.9.10") + version("kubernetes-client", "6.9.1") + version("grpc", "1.59.0") + + library("adventure-api", "net.kyori:adventure-api:4.14.0") + library("adventure-platform-bungeecord", "net.kyori:adventure-platform-bungeecord:4.3.1") + library("annotations-api", "org.apache.tomcat:annotations-api:6.0.53") + library("bungeecord-api", "net.md-5:bungeecord-api:1.20-R0.1") + library("folia-api", "dev.folia:folia-api:1.19.4-R0.1-SNAPSHOT") + library("guava", "com.google.guava:guava:32.1.3-jre") + library("jedis", "redis.clients:jedis:5.0.2") + library("kubernetes-client", "io.fabric8", "kubernetes-client").versionRef("kubernetes-client") + library("kubernetes-client-api", "io.fabric8", "kubernetes-client-api").versionRef("kubernetes-client") + library("kubernetes-client-http", "io.fabric8", "kubernetes-httpclient-okhttp").versionRef("kubernetes-client") + library("netty-shaded", "io.grpc:grpc-netty-shaded:1.59.0") + library("protobuf", "com.google.protobuf:protobuf-java:3.25.0") + library("grpc-common-protos", "com.google.api.grpc:proto-google-common-protos:2.28.0") + library("grpc-protobuf", "io.grpc", "grpc-protobuf").versionRef("grpc") + library("grpc-services", "io.grpc", "grpc-services").versionRef("grpc") + library("grpc-stub", "io.grpc", "grpc-stub").versionRef("grpc") + library("velocity-api", "com.velocitypowered:velocity-api:3.1.1") + + plugin("buildconfig", "com.github.gmazzo.buildconfig").version("4.1.2") + plugin("shadow", "com.github.johnrengelman.shadow").version("8.1.0") + plugin("ktlint", "org.jlleitschuh.gradle.ktlint").version("11.6.1") + plugin("detekt", "io.gitlab.arturbosch.detekt").version("1.23.1") + } + } +} + +fun includeBindingProject(name: String) { + include(":packages:${name}") + project(":packages:${name}").projectDir = file("packages/${name}/bindings/java") +} + +includeBindingProject("google-agones-sdk") +includeBindingProject("google-open-match-sdk") +includeBindingProject("shulker-sdk") + +include(":packages:shulker-proxy-api") +include(":packages:shulker-proxy-agent") + +include(":packages:shulker-server-api") +include(":packages:shulker-server-agent")