From 87d9ff09731fc5a0174e10ebb12a204db959b9a2 Mon Sep 17 00:00:00 2001 From: Spike Curtis Date: Mon, 7 Apr 2025 11:35:47 +0400 Subject: [PATCH] feat: add CODER_WORKSPACE_HOSTNAME_SUFFIX (#17268) Adds deployment option `CODER_WORKSPACE_HOSTNAME_SUFFIX`. This will eventually replace `CODER_SSH_HOSTNAME_PREFIX`, but we will do this slowly and support both for `coder ssh` for some time. Note that the name is changed to "workspace" hostname, since this suffix will also be used for Coder Connect on Coder Desktop, which is not limited to SSH. --- cli/testdata/coder_server_--help.golden | 7 ++++++- cli/testdata/server-config.yaml.golden | 6 +++++- coderd/apidoc/docs.go | 3 +++ coderd/apidoc/swagger.json | 3 +++ codersdk/deployment.go | 14 +++++++++++++- docs/reference/api/general.md | 1 + docs/reference/api/schemas.md | 3 +++ docs/reference/cli/server.md | 11 +++++++++++ enterprise/cli/testdata/coder_server_--help.golden | 7 ++++++- site/src/api/typesGenerated.ts | 1 + 10 files changed, 52 insertions(+), 4 deletions(-) diff --git a/cli/testdata/coder_server_--help.golden b/cli/testdata/coder_server_--help.golden index 80779201dc..7fe70860e2 100644 --- a/cli/testdata/coder_server_--help.golden +++ b/cli/testdata/coder_server_--help.golden @@ -78,7 +78,7 @@ OPTIONS: CLIENT OPTIONS: These options change the behavior of how clients interact with the Coder. -Clients include the coder cli, vs code extension, and the web UI. +Clients include the Coder CLI, Coder Desktop, IDE extensions, and the web UI. --cli-upgrade-message string, $CODER_CLI_UPGRADE_MESSAGE The upgrade message to display to users when a client/server mismatch @@ -98,6 +98,11 @@ Clients include the coder cli, vs code extension, and the web UI. The renderer to use when opening a web terminal. Valid values are 'canvas', 'webgl', or 'dom'. + --workspace-hostname-suffix string, $CODER_WORKSPACE_HOSTNAME_SUFFIX (default: coder) + Workspace hostnames use this suffix in SSH config and Coder Connect on + Coder Desktop. By default it is coder, resulting in names like + myworkspace.coder. + CONFIG OPTIONS: Use a YAML configuration file when your server launch become unwieldy. diff --git a/cli/testdata/server-config.yaml.golden b/cli/testdata/server-config.yaml.golden index 39ed5eb2c0..271593f753 100644 --- a/cli/testdata/server-config.yaml.golden +++ b/cli/testdata/server-config.yaml.golden @@ -490,11 +490,15 @@ disablePathApps: false # (default: , type: bool) disableOwnerWorkspaceAccess: false # These options change the behavior of how clients interact with the Coder. -# Clients include the coder cli, vs code extension, and the web UI. +# Clients include the Coder CLI, Coder Desktop, IDE extensions, and the web UI. client: # The SSH deployment prefix is used in the Host of the ssh config. # (default: coder., type: string) sshHostnamePrefix: coder. + # Workspace hostnames use this suffix in SSH config and Coder Connect on Coder + # Desktop. By default it is coder, resulting in names like myworkspace.coder. + # (default: coder, type: string) + workspaceHostnameSuffix: coder # These SSH config options will override the default SSH config options. Provide # options in "key=value" or "key value" format separated by commas.Using this # incorrectly can break SSH to your deployment, use cautiously. diff --git a/coderd/apidoc/docs.go b/coderd/apidoc/docs.go index c93af6a64a..c31ff68c9b 100644 --- a/coderd/apidoc/docs.go +++ b/coderd/apidoc/docs.go @@ -12019,6 +12019,9 @@ const docTemplate = `{ "wildcard_access_url": { "type": "string" }, + "workspace_hostname_suffix": { + "type": "string" + }, "write_config": { "type": "boolean" } diff --git a/coderd/apidoc/swagger.json b/coderd/apidoc/swagger.json index da4d7a4fcf..982daead86 100644 --- a/coderd/apidoc/swagger.json +++ b/coderd/apidoc/swagger.json @@ -10759,6 +10759,9 @@ "wildcard_access_url": { "type": "string" }, + "workspace_hostname_suffix": { + "type": "string" + }, "write_config": { "type": "boolean" } diff --git a/codersdk/deployment.go b/codersdk/deployment.go index a67682489f..a3e690ed67 100644 --- a/codersdk/deployment.go +++ b/codersdk/deployment.go @@ -393,6 +393,7 @@ type DeploymentValues struct { TermsOfServiceURL serpent.String `json:"terms_of_service_url,omitempty" typescript:",notnull"` Notifications NotificationsConfig `json:"notifications,omitempty" typescript:",notnull"` AdditionalCSPPolicy serpent.StringArray `json:"additional_csp_policy,omitempty" typescript:",notnull"` + WorkspaceHostnameSuffix serpent.String `json:"workspace_hostname_suffix,omitempty" typescript:",notnull"` Config serpent.YAMLConfigPath `json:"config,omitempty" typescript:",notnull"` WriteConfig serpent.Bool `json:"write_config,omitempty" typescript:",notnull"` @@ -944,7 +945,7 @@ func (c *DeploymentValues) Options() serpent.OptionSet { deploymentGroupClient = serpent.Group{ Name: "Client", Description: "These options change the behavior of how clients interact with the Coder. " + - "Clients include the coder cli, vs code extension, and the web UI.", + "Clients include the Coder CLI, Coder Desktop, IDE extensions, and the web UI.", YAML: "client", } deploymentGroupConfig = serpent.Group{ @@ -2549,6 +2550,17 @@ func (c *DeploymentValues) Options() serpent.OptionSet { Hidden: false, Default: "coder.", }, + { + Name: "Workspace Hostname Suffix", + Description: "Workspace hostnames use this suffix in SSH config and Coder Connect on Coder Desktop. By default it is coder, resulting in names like myworkspace.coder.", + Flag: "workspace-hostname-suffix", + Env: "CODER_WORKSPACE_HOSTNAME_SUFFIX", + YAML: "workspaceHostnameSuffix", + Group: &deploymentGroupClient, + Value: &c.WorkspaceHostnameSuffix, + Hidden: false, + Default: "coder", + }, { Name: "SSH Config Options", Description: "These SSH config options will override the default SSH config options. " + diff --git a/docs/reference/api/general.md b/docs/reference/api/general.md index c016ae5ddc..d1c4e2d597 100644 --- a/docs/reference/api/general.md +++ b/docs/reference/api/general.md @@ -515,6 +515,7 @@ curl -X GET http://coder-server:8080/api/v2/deployment/config \ "web_terminal_renderer": "string", "wgtunnel_host": "string", "wildcard_access_url": "string", + "workspace_hostname_suffix": "string", "write_config": true }, "options": [ diff --git a/docs/reference/api/schemas.md b/docs/reference/api/schemas.md index 4791967b53..a3b11bf0f9 100644 --- a/docs/reference/api/schemas.md +++ b/docs/reference/api/schemas.md @@ -2204,6 +2204,7 @@ CreateWorkspaceRequest provides options for creating a new workspace. Only one o "web_terminal_renderer": "string", "wgtunnel_host": "string", "wildcard_access_url": "string", + "workspace_hostname_suffix": "string", "write_config": true }, "options": [ @@ -2680,6 +2681,7 @@ CreateWorkspaceRequest provides options for creating a new workspace. Only one o "web_terminal_renderer": "string", "wgtunnel_host": "string", "wildcard_access_url": "string", + "workspace_hostname_suffix": "string", "write_config": true } ``` @@ -2748,6 +2750,7 @@ CreateWorkspaceRequest provides options for creating a new workspace. Only one o | `web_terminal_renderer` | string | false | | | | `wgtunnel_host` | string | false | | | | `wildcard_access_url` | string | false | | | +| `workspace_hostname_suffix` | string | false | | | | `write_config` | boolean | false | | | ## codersdk.DisplayApp diff --git a/docs/reference/cli/server.md b/docs/reference/cli/server.md index 888e569f9d..f55165bb39 100644 --- a/docs/reference/cli/server.md +++ b/docs/reference/cli/server.md @@ -1133,6 +1133,17 @@ Specify a YAML file to load configuration from. The SSH deployment prefix is used in the Host of the ssh config. +### --workspace-hostname-suffix + +| | | +|-------------|-----------------------------------------------| +| Type | string | +| Environment | $CODER_WORKSPACE_HOSTNAME_SUFFIX | +| YAML | client.workspaceHostnameSuffix | +| Default | coder | + +Workspace hostnames use this suffix in SSH config and Coder Connect on Coder Desktop. By default it is coder, resulting in names like myworkspace.coder. + ### --ssh-config-options | | | diff --git a/enterprise/cli/testdata/coder_server_--help.golden b/enterprise/cli/testdata/coder_server_--help.golden index 8ad6839c7a..8f383e145a 100644 --- a/enterprise/cli/testdata/coder_server_--help.golden +++ b/enterprise/cli/testdata/coder_server_--help.golden @@ -79,7 +79,7 @@ OPTIONS: CLIENT OPTIONS: These options change the behavior of how clients interact with the Coder. -Clients include the coder cli, vs code extension, and the web UI. +Clients include the Coder CLI, Coder Desktop, IDE extensions, and the web UI. --cli-upgrade-message string, $CODER_CLI_UPGRADE_MESSAGE The upgrade message to display to users when a client/server mismatch @@ -99,6 +99,11 @@ Clients include the coder cli, vs code extension, and the web UI. The renderer to use when opening a web terminal. Valid values are 'canvas', 'webgl', or 'dom'. + --workspace-hostname-suffix string, $CODER_WORKSPACE_HOSTNAME_SUFFIX (default: coder) + Workspace hostnames use this suffix in SSH config and Coder Connect on + Coder Desktop. By default it is coder, resulting in names like + myworkspace.coder. + CONFIG OPTIONS: Use a YAML configuration file when your server launch become unwieldy. diff --git a/site/src/api/typesGenerated.ts b/site/src/api/typesGenerated.ts index 2df1c351d9..1f5af62013 100644 --- a/site/src/api/typesGenerated.ts +++ b/site/src/api/typesGenerated.ts @@ -684,6 +684,7 @@ export interface DeploymentValues { readonly terms_of_service_url?: string; readonly notifications?: NotificationsConfig; readonly additional_csp_policy?: string; + readonly workspace_hostname_suffix?: string; readonly config?: string; readonly write_config?: boolean; readonly address?: string;