Skip to content
Snippets Groups Projects
Commit 37535e44 authored by Benedikt Wetzel's avatar Benedikt Wetzel
Browse files

reformat code

parent 8de1752e
No related branches found
No related tags found
1 merge request!201Introduce action commands
...@@ -8,10 +8,8 @@ import okhttp3.Response ...@@ -8,10 +8,8 @@ import okhttp3.Response
import theodolite.util.ActionCommandFailedException import theodolite.util.ActionCommandFailedException
import java.io.ByteArrayOutputStream import java.io.ByteArrayOutputStream
import java.time.Duration import java.time.Duration
import java.util.concurrent.CompletableFuture
import java.util.concurrent.CountDownLatch import java.util.concurrent.CountDownLatch
import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit
import javax.imageio.ImageTranscoder
import kotlin.properties.Delegates import kotlin.properties.Delegates
private val logger = KotlinLogging.logger {} private val logger = KotlinLogging.logger {}
...@@ -31,7 +29,7 @@ class ActionCommand(val client: NamespacedKubernetesClient) { ...@@ -31,7 +29,7 @@ class ActionCommand(val client: NamespacedKubernetesClient) {
* @param command The command to be executed. * @param command The command to be executed.
* @return * @return
*/ */
fun exec(matchLabels: MutableMap<String, String>, command: String, container: String = ""): Int { fun exec(matchLabels: MutableMap<String, String>, command: String, container: String = ""): Int {
val exitCode = ExitCode() val exitCode = ExitCode()
...@@ -70,7 +68,7 @@ class ActionCommand(val client: NamespacedKubernetesClient) { ...@@ -70,7 +68,7 @@ class ActionCommand(val client: NamespacedKubernetesClient) {
for (i in 1..tries) { for (i in 1..tries) {
try { try {
return getPodName(matchLabels) return getPodName(matchLabels)
} catch (e: Exception) { } catch (e: Exception) {
logger.warn { "Could not found any pod with specified matchlabels or pod is not ready." } logger.warn { "Could not found any pod with specified matchlabels or pod is not ready." }
} }
...@@ -80,13 +78,13 @@ class ActionCommand(val client: NamespacedKubernetesClient) { ...@@ -80,13 +78,13 @@ class ActionCommand(val client: NamespacedKubernetesClient) {
} }
private fun getPodName(matchLabels: MutableMap<String, String>): String { private fun getPodName(matchLabels: MutableMap<String, String>): String {
return try { return try {
val podNames = this.client val podNames = this.client
.pods() .pods()
.withLabels(matchLabels) .withLabels(matchLabels)
.list() .list()
.items .items
.map {it.metadata.name } .map { it.metadata.name }
podNames.first { podNames.first {
this.client.pods().withName(it).isReady this.client.pods().withName(it).isReady
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment