Skip to content

Commit

Permalink
Get settings via WebSocket
Browse files Browse the repository at this point in the history
  • Loading branch information
seachicken committed Nov 24, 2024
1 parent f7ab1c3 commit 426c6e3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/main/kotlin/inga/intellijinga/IngaService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.esotericsoftware.kryo.kryo5.minlog.Log
import com.github.dockerjava.api.DockerClient
import com.github.dockerjava.api.command.PullImageResultCallback
import com.github.dockerjava.api.exception.DockerException
import com.github.dockerjava.api.exception.NotModifiedException
import com.github.dockerjava.api.model.*
import com.github.dockerjava.core.DefaultDockerClientConfig
import com.github.dockerjava.core.DockerClientImpl
Expand Down Expand Up @@ -37,9 +38,9 @@ class IngaService(
) {
companion object {
const val INGA_IMAGE_NAME = "ghcr.io/seachicken/inga"
const val INGA_IMAGE_TAG = "0.25.2-java"
const val INGA_IMAGE_TAG = "0.25.4-java"
const val INGA_UI_IMAGE_NAME = "ghcr.io/seachicken/inga-ui"
const val INGA_UI_IMAGE_TAG = "0.9.0"
const val INGA_UI_IMAGE_TAG = "0.10.1"
}

private val ingaContainerName = "inga_${project.name}"
Expand Down Expand Up @@ -351,7 +352,11 @@ class IngaService(
.exec()
.find(isTargetContainer(containerName))
?.let {
client.stopContainerCmd(it.id).exec()
try {
client.stopContainerCmd(it.id).exec()
} catch (e: NotModifiedException) {
Log.info("INGA already requested to stop container", e)
}
}
}

Expand Down
15 changes: 15 additions & 0 deletions src/main/kotlin/inga/intellijinga/IngaWebSocketServer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,17 @@ class IngaWebSocketServer(

val gson = Gson()
when (gson.fromJson(message, BaseMessage::class.java).method) {
"getCallerHints" -> {
conn?.send(
gson.toJson(
GetCallerHintsResponse(
project.service<IngaSettings>().config?.servers?.associate { s ->
s.path to s.clients
} ?: emptyMap()
)
)
)
}
"getConnectionPaths" -> {
val getRequest = gson.fromJson(message, GetConnectionPathsRequest::class.java)
conn?.send(
Expand Down Expand Up @@ -88,6 +99,10 @@ class IngaWebSocketServer(

open class BaseMessage(val method: String)

data class GetCallerHintsResponse(
val callerHints: Map<String, List<Client>>
) : BaseMessage("getCallerHints")

data class GetConnectionPathsResponse(
val modulePaths: List<String>,
val callerHint: List<Client>?
Expand Down

0 comments on commit 426c6e3

Please sign in to comment.