Skip to content

Commit 8c5be82

Browse files
committed
Ensure version of Kotlin related packages are consistent
1 parent 558b70a commit 8c5be82

6 files changed

Lines changed: 21 additions & 21 deletions

File tree

.editorconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ ij_kotlin_method_parameters_right_paren_on_new_line = false
1313
ij_any_wrap_long_lines = false
1414
ij_formatter_off_tag = "@formatter:off"
1515
ij_formatter_on_tag = "@formatter:on"
16+
ij_kotlin_name_count_to_use_star_import = 50000
17+
ij_kotlin_name_count_to_use_star_import_for_members = 50000
1618
max_line_length = 256
1719
indent_style = space
1820
indent_size = 4

pom.xml

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@
1818
<maven.compiler.release>11</maven.compiler.release>
1919
<maven.compiler.target>11</maven.compiler.target>
2020
<version.fabric8.client>4.13.2</version.fabric8.client>
21-
<kotlin.version>1.5.21</kotlin.version>
21+
<kotlin.version>1.5.20</kotlin.version>
2222
<kotlin.compiler.incremental>true</kotlin.compiler.incremental>
23-
<version.arquillian_cube>1.18.2</version.arquillian_cube>
2423
<junit.jupiter.version>5.6.0</junit.jupiter.version>
2524
</properties>
2625

@@ -37,18 +36,11 @@
3736
</repository>
3837
</distributionManagement>
3938

40-
<repositories>
41-
<repository>
42-
<id>jcenter</id>
43-
<url>https://jcenter.bintray.com/</url>
44-
</repository>
45-
</repositories>
46-
4739
<dependencies>
4840
<dependency>
4941
<groupId>org.jetbrains.kotlinx</groupId>
5042
<artifactId>kotlinx-coroutines-core</artifactId>
51-
<version>1.3.9</version>
43+
<version>1.5.1</version>
5244
</dependency>
5345
<!-- https://mvnrepository.com/artifact/org.jetbrains.kotlin/kotlin-reflect -->
5446
<dependency>
@@ -69,8 +61,8 @@
6961
</dependency>
7062
<dependency>
7163
<groupId>io.github.microutils</groupId>
72-
<artifactId>kotlin-logging</artifactId>
73-
<version>1.7.8</version>
64+
<artifactId>kotlin-logging-jvm</artifactId>
65+
<version>2.0.10</version>
7466
</dependency>
7567
<dependency>
7668
<groupId>javax.json</groupId>

src/main/kotlin/eu/openanalytics/shinyproxyoperator/Operator.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ import kotlinx.coroutines.channels.Channel
4949
import kotlinx.coroutines.channels.SendChannel
5050
import mu.KotlinLogging
5151
import org.slf4j.LoggerFactory
52+
import java.util.*
5253
import kotlin.system.exitProcess
5354

5455

@@ -100,7 +101,7 @@ class Operator(client: NamespacedKubernetesClient? = null,
100101
}
101102

102103
this.mode = readConfigValue(mode, Mode.CLUSTERED, "SPO_MODE") {
103-
when (it.toLowerCase()) {
104+
when (it.lowercase(Locale.getDefault())) {
104105
"clustered" -> Mode.CLUSTERED
105106
"namespaced" -> Mode.NAMESPACED
106107
else -> error("Unsupported operator mode: $it")

src/main/kotlin/eu/openanalytics/shinyproxyoperator/controller/ResourceListener.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import io.fabric8.kubernetes.client.informers.cache.Lister
3131
import kotlinx.coroutines.channels.SendChannel
3232
import kotlinx.coroutines.runBlocking
3333
import mu.KotlinLogging
34+
import java.util.*
3435

3536
class ResourceListener<T : HasMetadata>(private val channel: SendChannel<ShinyProxyEvent>,
3637
informer: SharedIndexInformer<T>,
@@ -82,7 +83,7 @@ class ResourceListener<T : HasMetadata>(private val channel: SendChannel<ShinyPr
8283
private fun getShinyProxyOwnerRef(resource: HasMetadata): OwnerReference? {
8384
val ownerReferences = resource.metadata.ownerReferences
8485
for (ownerReference in ownerReferences) {
85-
if (ownerReference.kind.toLowerCase() == "shinyproxy") {
86+
if (ownerReference.kind.lowercase(Locale.getDefault()) == "shinyproxy") {
8687
return ownerReference
8788
}
8889
}

src/main/kotlin/eu/openanalytics/shinyproxyoperator/controller/ShinyProxyController.kt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ import io.fabric8.kubernetes.client.informers.SharedIndexInformer
3535
import io.fabric8.kubernetes.client.informers.cache.Lister
3636
import io.fabric8.kubernetes.client.internal.readiness.Readiness
3737
import kotlinx.coroutines.CancellationException
38-
import kotlinx.coroutines.GlobalScope
38+
import kotlinx.coroutines.CoroutineScope
39+
import kotlinx.coroutines.Dispatchers
3940
import kotlinx.coroutines.channels.Channel
4041
import kotlinx.coroutines.delay
4142
import kotlinx.coroutines.launch
@@ -59,8 +60,10 @@ class ShinyProxyController(private val channel: Channel<ShinyProxyEvent>,
5960

6061
private val logger = KotlinLogging.logger {}
6162

63+
private val scope = CoroutineScope(Dispatchers.Default)
64+
6265
suspend fun run() {
63-
GlobalScope.launch { scheduleAdditionalEvents() }
66+
scope.launch { scheduleAdditionalEvents() }
6467
while (true) {
6568
try {
6669
receiveAndHandleEvent()
@@ -284,7 +287,7 @@ class ShinyProxyController(private val channel: Channel<ShinyProxyEvent>,
284287
}
285288
}
286289

287-
private fun checkForObsoleteInstances() {
290+
private suspend fun checkForObsoleteInstances() {
288291
for (shinyProxy in shinyProxyLister.list()) {
289292
if (shinyProxy.status.instances.size > 1) {
290293
// this SP has more than one instance -> check if some of them are obsolete
@@ -317,7 +320,7 @@ class ShinyProxyController(private val channel: Channel<ShinyProxyEvent>,
317320
}
318321
}
319322

320-
fun deleteSingleShinyProxyInstance(shinyProxy: ShinyProxy, shinyProxyInstance: ShinyProxyInstance) {
323+
suspend fun deleteSingleShinyProxyInstance(shinyProxy: ShinyProxy, shinyProxyInstance: ShinyProxyInstance) {
321324
logger.info { "${shinyProxy.logPrefix(shinyProxyInstance)} DeleteSingleShinyProxyInstance [Step 1/3]: Update status" }
322325
// Important: update status BEFORE deleting, otherwise we will start reconciling this instance, before it's completely deleted
323326
updateStatus(shinyProxy) {
@@ -329,7 +332,7 @@ class ShinyProxyController(private val channel: Channel<ShinyProxyEvent>,
329332
logger.info { "${shinyProxy.logPrefix(shinyProxyInstance)} DeleteSingleShinyProxyInstance [Step 2/3]: Update Ingress" }
330333
ingressController.onRemoveInstance(shinyProxy, shinyProxyInstance)
331334

332-
GlobalScope.launch { // run async
335+
scope.launch { // run async
333336
// delete resources after delay of 30 seconds to ensure all routes are updated before deleting replicaset
334337
delay(30_000)
335338
logger.info { "${shinyProxy.logPrefix(shinyProxyInstance)} DeleteSingleShinyProxyInstance [Step 3/3]: Delete resources" }

src/main/kotlin/eu/openanalytics/shinyproxyoperator/ingress/skipper/IngressListener.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import io.fabric8.kubernetes.client.informers.cache.Lister
3535
import kotlinx.coroutines.channels.SendChannel
3636
import kotlinx.coroutines.runBlocking
3737
import mu.KotlinLogging
38+
import java.util.*
3839

3940
// TODO this has some duplicate code with ResourceListener<T>
4041
class IngressListener(private val channel: SendChannel<ShinyProxyEvent>,
@@ -94,12 +95,12 @@ class IngressListener(private val channel: SendChannel<ShinyProxyEvent>,
9495
private fun getShinyProxyOwnerRefByKind(resource: HasMetadata, kind: String): OwnerReference? {
9596
val ownerReferences = resource.metadata.ownerReferences
9697
for (ownerReference in ownerReferences) {
97-
if (ownerReference.kind.toLowerCase() == kind.toLowerCase()) {
98+
if (ownerReference.kind.lowercase(Locale.getDefault()) == kind.lowercase(Locale.getDefault())) {
9899
return ownerReference
99100
}
100101
}
101102

102103
return null
103104
}
104105

105-
}
106+
}

0 commit comments

Comments
 (0)