Skip to content

Commit 66ddbf8

Browse files
committed
impl: ability to customize the link to workspace creation in Dashboard
Some clients (Netflix in this specific case) rely on mainly their own dashboard tools instead of the Coder one. Two main reasons that were mentioned by Netflix: - aggregate many dev tools in a unified internal console - specific platform/security needs that their own UI handles better For this reason they would like the actions open up the Coder Dashboard (only Create workspace for now) to be fully customizable, and allow clients to override the URL. For `Create workspace` we now have a config that defaults $lastDeploymentUrl/templates, but it can be replaced with a relative URL to $lastDeploymentUrl or a complete new URL. For now the decision is to not allow configuration from UI since Netflix is the only target for this change, and they deploy at scale a templated settings.json.
1 parent 68cc4b8 commit 66ddbf8

File tree

6 files changed

+29
-7
lines changed

6 files changed

+29
-7
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,12 @@ storage paths. The options can be configured from the plugin's main Workspaces p
360360
- `Header command` command that outputs additional HTTP headers. Each line of output must be in the format key=value.
361361
The environment variable CODER_URL will be available to the command process.
362362

363+
- `lastDeploymentURL` the last Coder deployment URL that Coder Toolbox successfully authenticated to.
364+
365+
- `workspaceCreatePath` specifies the dashboard page’s relative path (to `lastDeploymentURL`) or full URL where users
366+
can create new workspaces. Helpful for customers that have their own in-house dashboards. Defaults to `/templates` if
367+
missing.
368+
363369
### TLS settings
364370

365371
The following options control the secure communication behavior of the plugin with Coder deployment and its available

src/main/kotlin/com/coder/toolbox/CoderRemoteProvider.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,14 @@ class CoderRemoteProvider(
224224
override val additionalPluginActions: StateFlow<List<ActionDescription>> = MutableStateFlow(
225225
listOf(
226226
Action(context, "Create workspace") {
227-
context.desktop.browse(client?.url?.withPath("/templates").toString()) {
227+
val wsCreatePath = context.settingsStore.workspaceCreatePath
228+
val url = if (wsCreatePath.startsWith("http://") || wsCreatePath.startsWith("https://")) {
229+
wsCreatePath
230+
} else {
231+
client?.url?.withPath(wsCreatePath).toString()
232+
}
233+
234+
context.desktop.browse(url) {
228235
context.ui.showErrorInfoPopup(it)
229236
}
230237
},

src/main/kotlin/com/coder/toolbox/settings/ReadOnlyCoderSettings.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,10 @@ interface ReadOnlyCoderSettings {
137137
*/
138138
val sshConfigOptions: String?
139139

140+
/**
141+
* A relative path or full URL to the dashboard page used for creating workspaces.
142+
*/
143+
val workspaceCreatePath: String
140144

141145
/**
142146
* The path where network information for SSH hosts are stored

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ class CoderSettingsStore(
8080
.normalize()
8181
.toString()
8282

83+
override val workspaceCreatePath: String
84+
get() = store[WORKSPACE_CREATE_PATH] ?: "/templates"
85+
8386
/**
8487
* Where the specified deployment should put its data.
8588
*/

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,7 @@ internal const val SSH_CONFIG_OPTIONS = "sshConfigOptions"
4646

4747
internal const val NETWORK_INFO_DIR = "networkInfoDir"
4848

49+
internal const val WORKSPACE_CREATE_PATH = "workspaceCreatePath"
50+
4951
internal const val SSH_AUTO_CONNECT_PREFIX = "ssh_auto_connect_"
5052

src/test/kotlin/com/coder/toolbox/util/URLExtensionsTest.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,21 @@ internal class URLExtensionsTest {
99
@Test
1010
fun testToURL() {
1111
assertEquals(
12-
URL("https", "localhost", 8080, "/path"),
13-
"https://localhost:8080/path".toURL(),
12+
expected = URI.create("https://localhost:8080/path").toURL(),
13+
actual = "https://localhost:8080/path".toURL(),
1414
)
1515
}
1616

1717
@Test
1818
fun testWithPath() {
1919
assertEquals(
20-
URL("https", "localhost", 8080, "/foo/bar"),
21-
URL("https", "localhost", 8080, "/").withPath("/foo/bar"),
20+
expected = "https://localhost:8080/foo/bar".toURL(),
21+
actual = "https://localhost:8080/".toURL().withPath("/foo/bar"),
2222
)
2323

2424
assertEquals(
25-
URL("https", "localhost", 8080, "/foo/bar"),
26-
URL("https", "localhost", 8080, "/old/path").withPath("/foo/bar"),
25+
expected = "https://localhost:8080/foo/bar".toURL(),
26+
actual = "https://localhost:8080/old/path".toURL().withPath("/foo/bar"),
2727
)
2828
}
2929

0 commit comments

Comments
 (0)