Skip to content

Commit d5930fe

Browse files
authored
refactor: remove unused logic in URI handler (#204)
PR #180 delegated all the logic for rest client and cli initialization to the usual authentication screen which provided better feedback/progress. But it also left over previous logic that can be removed.
1 parent 29bec3e commit d5930fe

File tree

1 file changed

+0
-48
lines changed

1 file changed

+0
-48
lines changed

‎src/main/kotlin/com/coder/toolbox/util/CoderProtocolHandler.kt‎

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ package com.coder.toolbox.util
22

33
importcom.coder.toolbox.CoderToolboxContext
44
importcom.coder.toolbox.cli.CoderCLIManager
5-
importcom.coder.toolbox.cli.ensureCLI
65
importcom.coder.toolbox.models.WorkspaceAndAgentStatus
7-
importcom.coder.toolbox.plugin.PluginManager
86
importcom.coder.toolbox.sdk.CoderRestClient
97
importcom.coder.toolbox.sdk.v2.models.Workspace
108
importcom.coder.toolbox.sdk.v2.models.WorkspaceAgent
@@ -154,29 +152,6 @@ open class CoderProtocolHandler(
154152
return workspace
155153
}
156154

157-
privatesuspendfunbuildRestClient(deploymentURL:String, token:String?): CoderRestClient?{
158-
try{
159-
return authenticate(deploymentURL, token)
160-
} catch (ex:Exception){
161-
context.logAndShowError(CAN_T_HANDLE_URI_TITLE, humanizeConnectionError(deploymentURL.toURL(), true, ex))
162-
returnnull
163-
}
164-
}
165-
166-
/**
167-
* Returns an authenticated Coder CLI.
168-
*/
169-
privatesuspendfunauthenticate(deploymentURL:String, token:String?): CoderRestClient{
170-
val client =CoderRestClient(
171-
context,
172-
deploymentURL.toURL(),
173-
token,
174-
PluginManager.pluginInfo.version
175-
)
176-
client.initializeSession()
177-
return client
178-
}
179-
180155
privatesuspendfun List<Workspace>.matchName(workspaceName:String, deploymentURL:String): Workspace?{
181156
val workspace =this.firstOrNull{it.name == workspaceName }
182157
if (workspace ==null){
@@ -326,29 +301,6 @@ open class CoderProtocolHandler(
326301
returntrue
327302
}
328303

329-
privatesuspendfunconfigureCli(
330-
deploymentURL:String,
331-
restClient:CoderRestClient,
332-
progressReporter: (String) ->Unit
333-
): CoderCLIManager{
334-
val cli = ensureCLI(
335-
context,
336-
deploymentURL.toURL(),
337-
restClient.buildInfo().version,
338-
progressReporter
339-
)
340-
341-
// We only need to log in if we are using token-based auth.
342-
if (restClient.token !=null){
343-
context.logger.info("Authenticating Coder CLI...")
344-
cli.login(restClient.token)
345-
}
346-
347-
context.logger.info("Configuring Coder CLI...")
348-
cli.configSsh(restClient.workspacesByAgents())
349-
return cli
350-
}
351-
352304
privatefunlaunchIde(
353305
environmentId:String,
354306
productCode:String,

0 commit comments

Comments
(0)