Skip to content

Commit a253388

Browse files
committed
fix: download the correct CLI signature for Windows
The signature for windows CLI follows the format: coder-windows-amd64.exe.asc Currently it is coded to coder-windows-amd64.asc which means the plugin always fail to find any signature for windows cli
1 parent f01d9f6 commit a253388

File tree

3 files changed

+21
-50
lines changed

3 files changed

+21
-50
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### Fixed
66

77
- fix class cast exception during signature verification
8+
- the correct CLI signature for Windows is now downloaded
89

910
## 0.5.1 - 2025-07-21
1011

src/main/kotlin/com/coder/toolbox/store/CoderSettingsStore.kt

Lines changed: 17 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -250,42 +250,17 @@ class CoderSettingsStore(
250250
/**
251251
* Return the name of the binary (with extension) for the provided OS and architecture.
252252
*/
253-
private fun getCoderCLIForOS(
254-
os: OS?,
255-
arch: Arch?,
256-
): String {
253+
private fun getCoderCLIForOS(os: OS?, arch: Arch?): String {
257254
logger.debug("Resolving binary for $os $arch")
258-
return buildCoderFileName(os, arch)
259-
}
260-
261-
/**
262-
* Return the name of the signature file (.asc) for the provided OS and architecture.
263-
*/
264-
private fun getCoderSignatureForOS(
265-
os: OS?,
266-
arch: Arch?,
267-
): String {
268-
logger.debug("Resolving signature for $os $arch")
269-
return buildCoderFileName(os, arch, true)
270-
}
271-
272-
/**
273-
* Build the coder file name based on OS, architecture, and whether it's a signature file.
274-
*/
275-
private fun buildCoderFileName(
276-
os: OS?,
277-
arch: Arch?,
278-
isSignature: Boolean = false
279-
): String {
280-
if (os == null) {
281-
logger.error("Could not resolve client OS and architecture, defaulting to WINDOWS AMD64")
282-
return if (isSignature) "coder-windows-amd64.asc" else "coder-windows-amd64.exe"
283-
}
284255

285-
val osName = when (os) {
286-
OS.WINDOWS -> "windows"
287-
OS.LINUX -> "linux"
288-
OS.MAC -> "darwin"
256+
val (osName, extension) = when (os) {
257+
OS.WINDOWS -> "windows" to ".exe"
258+
OS.LINUX -> "linux" to ""
259+
OS.MAC -> "darwin" to ""
260+
null -> {
261+
logger.error("Could not resolve client OS and architecture, defaulting to WINDOWS AMD64")
262+
return "coder-windows-amd64.exe"
263+
}
289264
}
290265

291266
val archName = when (arch) {
@@ -295,14 +270,17 @@ class CoderSettingsStore(
295270
else -> "amd64" // default fallback
296271
}
297272

298-
val extension = if (isSignature) ".asc" else when (os) {
299-
OS.WINDOWS -> ".exe"
300-
OS.LINUX, OS.MAC -> ""
301-
}
302-
303273
return "coder-$osName-$archName$extension"
304274
}
305275

276+
/**
277+
* Return the name of the signature file (.asc) for the provided OS and architecture.
278+
*/
279+
private fun getCoderSignatureForOS(os: OS?, arch: Arch?): String {
280+
logger.debug("Resolving signature for $os $arch")
281+
return "${getCoderCLIForOS(os, arch)}.asc"
282+
}
283+
306284
/**
307285
* Append the host to the path. For example, foo/bar could become
308286
* foo/bar/dev.coder.com-8080.

src/test/kotlin/com/coder/toolbox/store/CoderSettingsStoreTest.kt

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,11 @@ class CoderSettingsStoreTest {
3535

3636
@Test
3737
fun `Default CLI and signature for Windows AMD64`() =
38-
assertBinaryAndSignature("Windows 10", "amd64", "coder-windows-amd64.exe", "coder-windows-amd64.asc")
38+
assertBinaryAndSignature("Windows 10", "amd64", "coder-windows-amd64.exe", "coder-windows-amd64.exe.asc")
3939

4040
@Test
4141
fun `Default CLI and signature for Windows ARM64`() =
42-
assertBinaryAndSignature("Windows 10", "aarch64", "coder-windows-arm64.exe", "coder-windows-arm64.asc")
43-
44-
@Test
45-
fun `Default CLI and signature for Windows ARMV7`() =
46-
assertBinaryAndSignature("Windows 10", "armv7l", "coder-windows-armv7.exe", "coder-windows-armv7.asc")
42+
assertBinaryAndSignature("Windows 10", "aarch64", "coder-windows-arm64.exe", "coder-windows-arm64.exe.asc")
4743

4844
@Test
4945
fun `Default CLI and signature for Linux AMD64`() =
@@ -65,13 +61,9 @@ class CoderSettingsStoreTest {
6561
fun `Default CLI and signature for Mac ARM64`() =
6662
assertBinaryAndSignature("Mac OS X", "aarch64", "coder-darwin-arm64", "coder-darwin-arm64.asc")
6763

68-
@Test
69-
fun `Default CLI and signature for Mac ARMV7`() =
70-
assertBinaryAndSignature("Mac OS X", "armv7l", "coder-darwin-armv7", "coder-darwin-armv7.asc")
71-
7264
@Test
7365
fun `Default CLI and signature for unknown OS and Arch`() =
74-
assertBinaryAndSignature(null, null, "coder-windows-amd64.exe", "coder-windows-amd64.asc")
66+
assertBinaryAndSignature(null, null, "coder-windows-amd64.exe", "coder-windows-amd64.exe.asc")
7567

7668
@Test
7769
fun `Default CLI and signature for unknown Arch fallback on Linux`() =

0 commit comments

Comments
 (0)