Skip to content

Commit b6570ee

Browse files
committed
fix: drop support for agent name
1 parent 1be61f1 commit b6570ee

File tree

4 files changed

+31
-33
lines changed

4 files changed

+31
-33
lines changed

README.md

+3-4
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ jetbrains://gateway/com.coder.toolbox
7676
?url=http(s)://<your-coder-deployment>
7777
&token=<auth-token>
7878
&workspace=<workspace-name>
79-
&agent/agent_id=<agent-name-or-agent-id>
79+
&agent_id=<agent--id>
8080
&ide_product_code=<IDE-code>
8181
&ide_build_number=<IDE-build>
8282
&folder=<absolute-path-to-a-project-folder>
@@ -87,14 +87,13 @@ jetbrains://gateway/com.coder.toolbox
8787
| url | Your Coder deployment URL (encoded) | Yes |
8888
| token | Coder authentication token | Yes |
8989
| workspace | Name of the Coder workspace to connect to. | Yes |
90-
| agent | Name of the agent associated with the workspace | No |
9190
| agent_id | ID of the agent associated with the workspace | No |
9291
| ide_product_code | JetBrains IDE product code (e.g., GO for GoLand, RR for Rider) | No |
9392
| ide_build_number | Specific build number of the JetBrains IDE to install on the workspace | No |
9493
| folder | Absolute path to the project folder to open in the remote IDE (URL-encoded) | No |
9594

96-
If only a single agent is available, specifying an agent name or ID is optional. However, if multiple agents exist,
97-
you must provide either the name or ID to target a specific one. Note that this version of the Coder Toolbox plugin
95+
If only a single agent is available, specifying an agent ID is optional. However, if multiple agents exist,
96+
you must provide either the ID to target a specific one. Note that this version of the Coder Toolbox plugin
9897
does not automatically start agents if they are offline, so please ensure the selected agent is running before
9998
proceeding.
10099

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

+1-9
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,6 @@ internal fun resolveRedirects(url: URL): URL {
278278

279279
/**
280280
* Return the agent matching the provided agent ID or name in the parameters.
281-
* The name is ignored if the ID is set. If neither was supplied and the
282-
* workspace has only one agent, return that. Otherwise, throw an error.
283281
*
284282
* @throws [IllegalArgumentException]
285283
*/
@@ -297,8 +295,6 @@ internal fun getMatchingAgent(
297295
val agent =
298296
if (!parameters.agentID().isNullOrBlank()) {
299297
agents.firstOrNull { it.id.toString() == parameters.agentID() }
300-
} else if (!parameters.agentName().isNullOrBlank()) {
301-
agents.firstOrNull { it.name == parameters.agentName() }
302298
} else if (agents.size == 1) {
303299
agents.first()
304300
} else {
@@ -308,13 +304,9 @@ internal fun getMatchingAgent(
308304
if (agent == null) {
309305
if (!parameters.agentID().isNullOrBlank()) {
310306
throw IllegalArgumentException("The workspace \"${workspace.name}\" does not have an agent with ID \"${parameters.agentID()}\"")
311-
} else if (!parameters.agentName().isNullOrBlank()) {
312-
throw IllegalArgumentException(
313-
"The workspace \"${workspace.name}\"does not have an agent named \"${parameters.agentName()}\"",
314-
)
315307
} else {
316308
throw MissingArgumentException(
317-
"Unable to determine which agent to connect to; one of \"$AGENT_NAME\" or \"$AGENT_ID\" must be set because the workspace \"${workspace.name}\" has more than one agent",
309+
"Unable to determine which agent to connect to; \"$AGENT_ID\" must be set because the workspace \"${workspace.name}\" has more than one agent",
318310
)
319311
}
320312
}

src/main/kotlin/com/coder/toolbox/util/LinkMap.kt

-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ fun Map<String, String>.token() = this[TOKEN]
1515

1616
fun Map<String, String>.workspace() = this[WORKSPACE]
1717

18-
fun Map<String, String?>.agentName() = this[AGENT_NAME]
19-
2018
fun Map<String, String?>.agentID() = this[AGENT_ID]
2119

2220
fun Map<String, String>.ideProductCode() = this[IDE_PRODUCT_CODE]

src/test/kotlin/com/coder/toolbox/util/LinkHandlerTest.kt

+27-18
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,21 @@ internal class LinkHandlerTest {
5454

5555
val tests =
5656
listOf(
57-
Pair(mapOf("agent" to "agent_name"), "9a920eee-47fb-4571-9501-e4b3120c12f2"),
58-
Pair(mapOf("agent_id" to "9a920eee-47fb-4571-9501-e4b3120c12f2"), "9a920eee-47fb-4571-9501-e4b3120c12f2"),
59-
Pair(mapOf("agent" to "agent_name_2"), "fb3daea4-da6b-424d-84c7-36b90574cfef"),
60-
Pair(mapOf("agent_id" to "fb3daea4-da6b-424d-84c7-36b90574cfef"), "fb3daea4-da6b-424d-84c7-36b90574cfef"),
61-
Pair(mapOf("agent" to "agent_name_3"), "b0e4c54d-9ba9-4413-8512-11ca1e826a24"),
62-
Pair(mapOf("agent_id" to "b0e4c54d-9ba9-4413-8512-11ca1e826a24"), "b0e4c54d-9ba9-4413-8512-11ca1e826a24"),
57+
Pair(
58+
mapOf("agent_id" to "9a920eee-47fb-4571-9501-e4b3120c12f2"),
59+
"9a920eee-47fb-4571-9501-e4b3120c12f2"
60+
),
61+
Pair(
62+
mapOf("agent_id" to "fb3daea4-da6b-424d-84c7-36b90574cfef"),
63+
"fb3daea4-da6b-424d-84c7-36b90574cfef"
64+
),
65+
Pair(
66+
mapOf("agent_id" to "b0e4c54d-9ba9-4413-8512-11ca1e826a24"),
67+
"b0e4c54d-9ba9-4413-8512-11ca1e826a24"
68+
),
6369
// Prefer agent_id.
6470
Pair(
6571
mapOf(
66-
"agent" to "agent_name",
6772
"agent_id" to "b0e4c54d-9ba9-4413-8512-11ca1e826a24",
6873
),
6974
"b0e4c54d-9ba9-4413-8512-11ca1e826a24",
@@ -81,15 +86,14 @@ internal class LinkHandlerTest {
8186
val tests =
8287
listOf(
8388
Triple(emptyMap(), MissingArgumentException::class, "Unable to determine"),
84-
Triple(mapOf("agent" to ""), MissingArgumentException::class, "Unable to determine"),
8589
Triple(mapOf("agent_id" to ""), MissingArgumentException::class, "Unable to determine"),
86-
Triple(mapOf("agent" to null), MissingArgumentException::class, "Unable to determine"),
8790
Triple(mapOf("agent_id" to null), MissingArgumentException::class, "Unable to determine"),
88-
Triple(mapOf("agent" to "ws"), IllegalArgumentException::class, "agent named"),
89-
Triple(mapOf("agent" to "ws.agent_name"), IllegalArgumentException::class, "agent named"),
90-
Triple(mapOf("agent" to "agent_name_4"), IllegalArgumentException::class, "agent named"),
9191
Triple(mapOf("agent_id" to "not-a-uuid"), IllegalArgumentException::class, "agent with ID"),
92-
Triple(mapOf("agent_id" to "ceaa7bcf-1612-45d7-b484-2e0da9349168"), IllegalArgumentException::class, "agent with ID"),
92+
Triple(
93+
mapOf("agent_id" to "ceaa7bcf-1612-45d7-b484-2e0da9349168"),
94+
IllegalArgumentException::class,
95+
"agent with ID"
96+
),
9397
// Will ignore agent if agent_id is set even if agent matches.
9498
Triple(
9599
mapOf(
@@ -139,10 +143,11 @@ internal class LinkHandlerTest {
139143
val ws = DataGen.workspace("ws", agents = oneAgent)
140144
val tests =
141145
listOf(
142-
Triple(mapOf("agent" to "ws"), IllegalArgumentException::class, "agent named"),
143-
Triple(mapOf("agent" to "ws.agent_name_3"), IllegalArgumentException::class, "agent named"),
144-
Triple(mapOf("agent" to "agent_name_4"), IllegalArgumentException::class, "agent named"),
145-
Triple(mapOf("agent_id" to "ceaa7bcf-1612-45d7-b484-2e0da9349168"), IllegalArgumentException::class, "agent with ID"),
146+
Triple(
147+
mapOf("agent_id" to "ceaa7bcf-1612-45d7-b484-2e0da9349168"),
148+
IllegalArgumentException::class,
149+
"agent with ID"
150+
),
146151
)
147152

148153
tests.forEach {
@@ -166,7 +171,11 @@ internal class LinkHandlerTest {
166171
Triple(mapOf("agent" to null), IllegalArgumentException::class, "has no agents"),
167172
Triple(mapOf("agent_id" to null), IllegalArgumentException::class, "has no agents"),
168173
Triple(mapOf("agent" to "agent_name"), IllegalArgumentException::class, "has no agents"),
169-
Triple(mapOf("agent_id" to "9a920eee-47fb-4571-9501-e4b3120c12f2"), IllegalArgumentException::class, "has no agents"),
174+
Triple(
175+
mapOf("agent_id" to "9a920eee-47fb-4571-9501-e4b3120c12f2"),
176+
IllegalArgumentException::class,
177+
"has no agents"
178+
),
170179
)
171180

172181
tests.forEach {

0 commit comments

Comments
 (0)