1
1
package com.coder.toolbox
2
2
3
3
import com.coder.toolbox.cli.CoderCLIManager
4
+ import com.coder.toolbox.logger.CoderLoggerFactory
4
5
import com.coder.toolbox.sdk.CoderRestClient
5
6
import com.coder.toolbox.sdk.v2.models.WorkspaceStatus
6
7
import com.coder.toolbox.services.CoderSecretsService
@@ -34,7 +35,6 @@ import kotlinx.coroutines.delay
34
35
import kotlinx.coroutines.isActive
35
36
import kotlinx.coroutines.launch
36
37
import okhttp3.OkHttpClient
37
- import org.slf4j.LoggerFactory
38
38
import java.net.URI
39
39
import java.net.URL
40
40
import kotlin.coroutines.cancellation.CancellationException
@@ -43,8 +43,8 @@ import kotlin.time.Duration.Companion.seconds
43
43
class CoderRemoteProvider (
44
44
private val serviceLocator : ServiceLocator ,
45
45
private val httpClient : OkHttpClient ,
46
- ) : RemoteProvider {
47
- private val logger = LoggerFactory .getLogger(javaClass)
46
+ ) : RemoteProvider( " Coder " ) {
47
+ private val logger = CoderLoggerFactory .getLogger(javaClass)
48
48
49
49
private val ui: ToolboxUi = serviceLocator.getService(ToolboxUi ::class .java)
50
50
private val consumer: RemoteEnvironmentConsumer = serviceLocator.getService(RemoteEnvironmentConsumer ::class .java)
@@ -185,18 +185,18 @@ class CoderRemoteProvider(
185
185
consumer.consumeEnvironments(emptyList(), true )
186
186
}
187
187
188
- override fun getName (): String = " Coder"
189
- override fun getSvgIcon (): SvgIcon =
188
+ override val svgIcon: SvgIcon =
190
189
SvgIcon (this ::class .java.getResourceAsStream(" /icon.svg" )?.readAllBytes() ? : byteArrayOf())
191
190
192
- override fun getNoEnvironmentsSvgIcon (): ByteArray =
193
- this ::class .java.getResourceAsStream(" /icon.svg" )?.readAllBytes() ? : byteArrayOf()
191
+ override val noEnvironmentsSvgIcon : SvgIcon ? =
192
+ SvgIcon ( this ::class .java.getResourceAsStream(" /icon.svg" )?.readAllBytes() ? : byteArrayOf() )
194
193
195
194
/* *
196
195
* TODO@JB: It would be nice to show "loading workspaces" at first but it
197
196
* appears to be only called once.
198
197
*/
199
- override fun getNoEnvironmentsDescription (): String = " No workspaces yet"
198
+ override val noEnvironmentsDescription: String? = " No workspaces yet"
199
+
200
200
201
201
/* *
202
202
* TODO@JB: Supposedly, setting this to false causes the new environment
@@ -205,7 +205,7 @@ class CoderRemoteProvider(
205
205
* this changes it would be nice to have a new spot to show the
206
206
* URL.
207
207
*/
208
- override fun canCreateNewEnvironments () : Boolean = false
208
+ override val canCreateNewEnvironments: Boolean = false
209
209
210
210
/* *
211
211
* Just displays the deployment URL at the moment, but we could use this as
@@ -216,7 +216,7 @@ class CoderRemoteProvider(
216
216
/* *
217
217
* We always show a list of environments.
218
218
*/
219
- override fun isSingleEnvironment () : Boolean = false
219
+ override val isSingleEnvironment: Boolean = false
220
220
221
221
/* *
222
222
* TODO: Possibly a good idea to start/stop polling based on visibility, at
@@ -241,9 +241,11 @@ class CoderRemoteProvider(
241
241
*/
242
242
override fun handleUri (uri : URI ) {
243
243
val params = uri.toQueryParameters()
244
- val name = linkHandler.handle(params)
245
- // TODO@JB: Now what? How do we actually connect this workspace?
246
- logger.debug(" External request for {}: {}" , name, uri)
244
+ coroutineScope.launch {
245
+ val name = linkHandler.handle(params)
246
+ // TODO@JB: Now what? How do we actually connect this workspace?
247
+ logger.debug(" External request for {}: {}" , name, uri)
248
+ }
247
249
}
248
250
249
251
/* *
0 commit comments