Skip to content

Commit e20d503

Browse files
committed
Add QUERY token source and show deployment host
When you connect via a Gateway link it might not be obvious if the deployment URL is wrong.
1 parent 77787a8 commit e20d503

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

src/main/kotlin/com/coder/gateway/CoderRemoteConnectionHandle.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ class CoderRemoteConnectionHandle {
107107
* Generic function to ask for input.
108108
*/
109109
@JvmStatic
110-
fun ask(comment: String, isError: Boolean, link: Pair<String, String>?, default: String?): String? {
110+
fun ask(comment: String, isError: Boolean = false, link: Pair<String, String>? = null, default: String? = null): String? {
111111
var inputFromUser: String? = null
112112
ApplicationManager.getApplication().invokeAndWait({
113113
lateinit var inputTextField: JBTextField
@@ -169,7 +169,7 @@ class CoderRemoteConnectionHandle {
169169
} else if (!isRetry && useExisting) {
170170
val (u, t) = CoderCLIManager.readConfig()
171171
if (url == u?.toURL() && !t.isNullOrBlank() && t != existingToken) {
172-
logger.info("Injecting token from CLI config")
172+
logger.info("Injecting token for $url from CLI config")
173173
tokenSource = TokenSource.CONFIG
174174
existingToken = t
175175
}
@@ -178,8 +178,10 @@ class CoderRemoteConnectionHandle {
178178
CoderGatewayBundle.message(
179179
if (isRetry) "gateway.connector.view.workspaces.token.rejected"
180180
else if (tokenSource == TokenSource.CONFIG) "gateway.connector.view.workspaces.token.injected"
181+
else if (tokenSource == TokenSource.QUERY) "gateway.connector.view.workspaces.token.query"
181182
else if (existingToken.isNotBlank()) "gateway.connector.view.workspaces.token.comment"
182-
else "gateway.connector.view.workspaces.token.none"
183+
else "gateway.connector.view.workspaces.token.none",
184+
url.host,
183185
),
184186
isRetry,
185187
Pair(

src/main/kotlin/com/coder/gateway/models/CoderWorkspacesWizardModel.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package com.coder.gateway.models
33
enum class TokenSource {
44
CONFIG, // Pulled from the Coder CLI config.
55
USER, // Input by the user.
6+
QUERY, // From the Gateway link as a query parameter.
67
LAST_USED, // Last used token, either from storage or current run.
78
}
89

src/main/resources/messages/CoderGatewayBundle.properties

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,11 @@ gateway.connector.view.workspaces.connect.download-failed=Failed to download Cod
3636
gateway.connector.view.workspaces.connect.ssl-error=Connection to {0} failed: {1}. See the \
3737
<a href='https://coder.com/docs/v2/latest/ides/gateway#configuring-the-gateway-plugin-to-use-internal-certificates'>documentation for TLS certificates</a> \
3838
for information on how to make your system trust certificates coming from your deployment.
39-
gateway.connector.view.workspaces.token.comment=The last used token is shown above.
40-
gateway.connector.view.workspaces.token.rejected=This token was rejected.
41-
gateway.connector.view.workspaces.token.injected=This token was pulled from your CLI config.
42-
gateway.connector.view.workspaces.token.none=No existing token found.
39+
gateway.connector.view.workspaces.token.comment=The last used token for {0} is shown above.
40+
gateway.connector.view.workspaces.token.rejected=This token was rejected by {0}.
41+
gateway.connector.view.workspaces.token.injected=This token was pulled from your CLI config for {0}.
42+
gateway.connector.view.workspaces.token.query=This token was pulled from the Gateway link from {0}.
43+
gateway.connector.view.workspaces.token.none=No existing token for {0} found.
4344
gateway.connector.view.coder.connect-ssh=Establishing SSH connection to remote worker...
4445
gateway.connector.view.coder.connect-ssh.retry=Establishing SSH connection to remote worker (attempt {0})...
4546
gateway.connector.view.coder.retrieve-ides=Retrieving IDEs...

0 commit comments

Comments
 (0)