Skip to content

Commit b2b472c

Browse files
committed
Check that CLI downloads the first time
Getting a test failure on macOS and just want to make sure it does download the first time.
1 parent a9bedcb commit b2b472c

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

src/main/kotlin/com/coder/gateway/views/steps/CoderWorkspacesStepView.kt

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import com.coder.gateway.sdk.ex.WorkspaceResponseException
2424
import com.coder.gateway.sdk.toURL
2525
import com.coder.gateway.sdk.v2.models.Workspace
2626
import com.coder.gateway.sdk.withPath
27+
import com.coder.gateway.services.CoderSettingsState
2728
import com.intellij.ide.ActivityTracker
2829
import com.intellij.ide.BrowserUtil
2930
import com.intellij.ide.IdeBundle
@@ -77,6 +78,7 @@ import java.awt.font.TextAttribute
7778
import java.awt.font.TextAttribute.UNDERLINE_ON
7879
import java.net.SocketTimeoutException
7980
import java.net.URL
81+
import java.nio.file.Path
8082
import javax.swing.Icon
8183
import javax.swing.JCheckBox
8284
import javax.swing.JTable
@@ -97,6 +99,7 @@ class CoderWorkspacesStepView(val setNextButtonEnabled: (Boolean) -> Unit) : Cod
9799
private var localWizardModel = CoderWorkspacesWizardModel()
98100
private val coderClient: CoderRestClientService = service()
99101
private val iconDownloader: TemplateIconDownloader = service()
102+
private val settings: CoderSettingsState = service()
100103

101104
private val appPropertiesService: PropertiesComponent = service()
102105

@@ -462,7 +465,11 @@ class CoderWorkspacesStepView(val setNextButtonEnabled: (Boolean) -> Unit) : Cod
462465
appPropertiesService.setValue(SESSION_TOKEN, token)
463466

464467
this.indicator.text = "Downloading Coder CLI..."
465-
val cliManager = CoderCLIManager(deploymentURL)
468+
val cliManager = CoderCLIManager(
469+
deploymentURL,
470+
if (settings.binaryDestination.isNotBlank()) Path.of(settings.binaryDestination) else null,
471+
settings.binarySource,
472+
)
466473
cliManager.downloadCLI()
467474

468475
this.indicator.text = "Authenticating Coder CLI..."
@@ -713,7 +720,11 @@ class CoderWorkspacesStepView(val setNextButtonEnabled: (Boolean) -> Unit) : Cod
713720
poller?.cancel()
714721

715722
logger.info("Configuring Coder CLI...")
716-
val cliManager = CoderCLIManager(wizardModel.coderURL.toURL())
723+
val cliManager = CoderCLIManager(
724+
wizardModel.coderURL.toURL(),
725+
if (settings.binaryDestination.isNotBlank()) Path.of(settings.binaryDestination) else null,
726+
settings.binarySource,
727+
)
717728
cliManager.configSsh(listTableModelOfWorkspaces.items)
718729

719730
logger.info("Opening IDE and Project Location window for ${workspace.name}")

src/test/groovy/CoderCLIManagerTest.groovy

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,12 +209,13 @@ class CoderCLIManagerTest extends Specification {
209209
def ccm = new CoderCLIManager(new URL(url), tmpdir)
210210

211211
when:
212-
ccm.downloadCLI()
212+
def downloaded1 = ccm.downloadCLI()
213213
ccm.localBinaryPath.toFile().setLastModified(0)
214-
def downloaded = ccm.downloadCLI()
214+
def downloaded2 = ccm.downloadCLI()
215215

216216
then:
217-
!downloaded
217+
downloaded1
218+
!downloaded2
218219
ccm.localBinaryPath.toFile().lastModified() == 0
219220

220221
cleanup:

0 commit comments

Comments
 (0)