Skip to content

Commit 5bb8182

Browse files
committed
Include port in sub-directory if it is set
1 parent 6636f31 commit 5bb8182

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/main/kotlin/com/coder/gateway/sdk/CoderCLIManager.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ class CoderCLIManager @JvmOverloads constructor(deployment: URL, destinationDir:
3434
deployment.port,
3535
"/bin/$binaryName"
3636
)
37-
localBinaryPath = destinationDir.resolve(deployment.host).resolve(binaryName)
37+
val subdir = if (deployment.port > 0) "${deployment.host}-${deployment.port}" else deployment.host
38+
localBinaryPath = destinationDir.resolve(subdir).resolve(binaryName)
3839
}
3940
/**
4041
* Return the name of the binary (with extension) for the provided OS and

src/test/groovy/CoderCLIManagerTest.groovy

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ class CoderCLIManagerTest extends spock.lang.Specification {
3737
ccm.localBinaryPath.getParent() == CoderCLIManager.getDataDir().resolve("test.coder.invalid")
3838
}
3939

40+
def "includes port in sub-directory if included"() {
41+
given:
42+
def ccm = new CoderCLIManager(new URL("https://test.coder.invalid:3000"))
43+
44+
expect:
45+
ccm.localBinaryPath.getParent() == CoderCLIManager.getDataDir().resolve("test.coder.invalid-3000")
46+
}
47+
4048
def "downloads a working cli"() {
4149
given:
4250
def ccm = createCLIManager()

0 commit comments

Comments
 (0)