- Notifications
You must be signed in to change notification settings - Fork16
feature: Add setting to remove/set custom workspace filter for connections view.#490
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
6 commits Select commitHold shift + click to select a range
547e5ef
more work
bcpeinhardt3e8d004
tests
bcpeinhardta4cf9ae
owner field in table
bcpeinhardt5cae52a
changelog
bcpeinhardt22631ab
Merge branch 'main' into bcpeinhardt/workspaces-filter
bcpeinhardt4268bbf
resolve asher's comments
bcpeinhardtFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
6 changes: 6 additions & 0 deletionsCHANGELOG.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletionssrc/main/kotlin/com/coder/gateway/CoderSettingsConfigurable.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
55 changes: 43 additions & 12 deletionssrc/main/kotlin/com/coder/gateway/cli/CoderCLIManager.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -3,6 +3,9 @@ | ||
import com.coder.gateway.cli.ex.MissingVersionException | ||
import com.coder.gateway.cli.ex.ResponseException | ||
import com.coder.gateway.cli.ex.SSHConfigFormatException | ||
import com.coder.gateway.sdk.v2.models.User | ||
import com.coder.gateway.sdk.v2.models.Workspace | ||
import com.coder.gateway.sdk.v2.models.WorkspaceAgent | ||
import com.coder.gateway.settings.CoderSettings | ||
import com.coder.gateway.settings.CoderSettingsState | ||
import com.coder.gateway.util.CoderHostnameVerifier | ||
@@ -219,11 +222,12 @@ | ||
* This can take supported features for testing purposes only. | ||
*/ | ||
fun configSsh( | ||
workspacesAndAgents: Set<Pair<Workspace, WorkspaceAgent>>, | ||
currentUser: User, | ||
feats: Features = features, | ||
) { | ||
logger.info("Configuring SSH config at ${settings.sshConfigPath}") | ||
writeSSHConfig(modifySSHConfig(readSSHConfig(),workspacesAndAgents, feats, currentUser)) | ||
} | ||
/** | ||
@@ -245,8 +249,9 @@ | ||
*/ | ||
private fun modifySSHConfig( | ||
contents: String?, | ||
workspaceNames: Set<Pair<Workspace, WorkspaceAgent>>, | ||
feats: Features, | ||
currentUser: User, | ||
): String? { | ||
val host = deploymentURL.safeHost() | ||
val startBlock = "# --- START CODER JETBRAINS $host" | ||
@@ -287,8 +292,8 @@ | ||
System.lineSeparator() + endBlock, | ||
transform = { | ||
""" | ||
Host ${getHostName(deploymentURL, it.first, currentUser, it.second)} | ||
ProxyCommand ${proxyArgs.joinToString(" ")} ${getWorkspaceParts(it.first, it.second)} | ||
ConnectTimeout 0 | ||
StrictHostKeyChecking no | ||
UserKnownHostsFile /dev/null | ||
@@ -299,8 +304,8 @@ | ||
.plus("\n") | ||
.plus( | ||
""" | ||
Host ${getBackgroundHostName(deploymentURL, it.first, currentUser, it.second)} | ||
ProxyCommand ${backgroundProxyArgs.joinToString(" ")} ${getWorkspaceParts(it.first, it.second)} | ||
ConnectTimeout 0 | ||
StrictHostKeyChecking no | ||
UserKnownHostsFile /dev/null | ||
@@ -478,21 +483,47 @@ | ||
private val tokenRegex = "--token [^ ]+".toRegex() | ||
/** | ||
* This function returns the ssh host name generated for connecting to the workspace. | ||
*/ | ||
@JvmStatic | ||
fun getHostName( | ||
url: URL, | ||
workspace: Workspace, | ||
currentUser: User, | ||
agent: WorkspaceAgent, | ||
): String = | ||
// For a user's own workspace, we use the old syntax without a username for backwards compatibility, | ||
// since the user might have recent connections that still use the old syntax. | ||
if (currentUser.username == workspace.ownerName) { | ||
"coder-jetbrains--${workspace.name}.${agent.name}--${url.safeHost()}" | ||
bcpeinhardt marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
} else { | ||
"coder-jetbrains--${workspace.ownerName}--${workspace.name}.${agent.name}--${url.safeHost()}" | ||
} | ||
fun getBackgroundHostName( | ||
url: URL, | ||
workspace: Workspace, | ||
currentUser: User, | ||
agent: WorkspaceAgent, | ||
): String { | ||
return getHostName(url, workspace, currentUser, agent) + "--bg" | ||
} | ||
/** | ||
* This function returns the identifier for the workspace to pass to the | ||
* coder ssh proxy command. | ||
*/ | ||
@JvmStatic | ||
fun getWorkspaceParts( | ||
workspace: Workspace, | ||
agent: WorkspaceAgent, | ||
): String = "${workspace.ownerName}/${workspace.name}.${agent.name}" | ||
@JvmStatic | ||
fun getBackgroundHostName( | ||
bcpeinhardt marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
hostname: String, | ||
): String = hostname + "--bg" | ||
} | ||
} |
15 changes: 4 additions & 11 deletionssrc/main/kotlin/com/coder/gateway/sdk/CoderRestClient.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletionssrc/main/kotlin/com/coder/gateway/sdk/v2/models/Workspace.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletionssrc/main/kotlin/com/coder/gateway/settings/CoderSettings.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
5 changes: 1 addition & 4 deletionssrc/main/kotlin/com/coder/gateway/util/Dialogs.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletionssrc/main/kotlin/com/coder/gateway/util/LinkHandler.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
13 changes: 6 additions & 7 deletionssrc/main/kotlin/com/coder/gateway/views/steps/CoderWorkspaceProjectIDEStepView.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
36 changes: 34 additions & 2 deletionssrc/main/kotlin/com/coder/gateway/views/steps/CoderWorkspacesStepView.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.