From b4f74990b0cf563b852c801a10ffabaa3945419d Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Wed, 19 Jul 2023 13:14:38 +0200 Subject: [PATCH] feat: add custom docs URL to deployment config --- cli/testdata/coder_server_--help.golden | 3 +++ cli/testdata/server-config.yaml.golden | 3 +++ coderd/apidoc/docs.go | 3 +++ coderd/apidoc/swagger.json | 3 +++ codersdk/deployment.go | 11 ++++++++ docs/api/general.md | 13 +++++++++ docs/api/schemas.md | 27 +++++++++++++++++++ docs/cli/server.md | 10 +++++++ .../cli/testdata/coder_server_--help.golden | 3 +++ site/src/api/typesGenerated.ts | 1 + 10 files changed, 77 insertions(+) diff --git a/cli/testdata/coder_server_--help.golden b/cli/testdata/coder_server_--help.golden index d09060409c034..66bd33d96b5c9 100644 --- a/cli/testdata/coder_server_--help.golden +++ b/cli/testdata/coder_server_--help.golden @@ -128,6 +128,9 @@ Use a YAML configuration file when your server launch become unwieldy. --access-url url, $CODER_ACCESS_URL The URL that users will use to access the Coder deployment. + --docs-url url, $CODER_DOCS_URL + Specifies the custom docs URL. + --proxy-trusted-headers string-array, $CODER_PROXY_TRUSTED_HEADERS Headers to trust for forwarding IP addresses. e.g. Cf-Connecting-Ip, True-Client-Ip, X-Forwarded-For. diff --git a/cli/testdata/server-config.yaml.golden b/cli/testdata/server-config.yaml.golden index 6a7062d56eebe..e629ee8312a90 100644 --- a/cli/testdata/server-config.yaml.golden +++ b/cli/testdata/server-config.yaml.golden @@ -6,6 +6,9 @@ networking: # "*.example.com". # (default: , type: url) wildcardAccessURL: + # Specifies the custom docs URL. + # (default: , type: url) + docsURL: # Specifies whether to redirect requests that do not match the access URL host. # (default: , type: bool) redirectToAccessURL: false diff --git a/coderd/apidoc/docs.go b/coderd/apidoc/docs.go index 11f8124734c0e..dd6c958448391 100644 --- a/coderd/apidoc/docs.go +++ b/coderd/apidoc/docs.go @@ -7439,6 +7439,9 @@ const docTemplate = `{ "disable_session_expiry_refresh": { "type": "boolean" }, + "docs_url": { + "$ref": "#/definitions/clibase.URL" + }, "enable_terraform_debug_mode": { "type": "boolean" }, diff --git a/coderd/apidoc/swagger.json b/coderd/apidoc/swagger.json index 124dad8ccd6ec..aa2fedba869a6 100644 --- a/coderd/apidoc/swagger.json +++ b/coderd/apidoc/swagger.json @@ -6644,6 +6644,9 @@ "disable_session_expiry_refresh": { "type": "boolean" }, + "docs_url": { + "$ref": "#/definitions/clibase.URL" + }, "enable_terraform_debug_mode": { "type": "boolean" }, diff --git a/codersdk/deployment.go b/codersdk/deployment.go index 79266441b6dc6..73e3c2dd5d450 100644 --- a/codersdk/deployment.go +++ b/codersdk/deployment.go @@ -120,6 +120,7 @@ type DeploymentValues struct { Verbose clibase.Bool `json:"verbose,omitempty"` AccessURL clibase.URL `json:"access_url,omitempty"` WildcardAccessURL clibase.URL `json:"wildcard_access_url,omitempty"` + DocsURL clibase.URL `json:"docs_url,omitempty"` RedirectToAccessURL clibase.Bool `json:"redirect_to_access_url,omitempty"` // HTTPAddress is a string because it may be set to zero to disable. HTTPAddress clibase.String `json:"http_address,omitempty" typescript:",notnull"` @@ -534,6 +535,16 @@ when required by your organization's security policy.`, YAML: "wildcardAccessURL", Annotations: clibase.Annotations{}.Mark(annotationExternalProxies, "true"), }, + { + Name: "Docs URL", + Description: "Specifies the custom docs URL.", + Value: &c.DocsURL, + Flag: "docs-url", + Env: "CODER_DOCS_URL", + Group: &deploymentGroupNetworking, + YAML: "docsURL", + Annotations: clibase.Annotations{}.Mark(annotationExternalProxies, "true"), + }, redirectToAccessURL, { Name: "Autobuild Poll Interval", diff --git a/docs/api/general.md b/docs/api/general.md index 9ac3ff38083e8..4b19ecd4f87e2 100644 --- a/docs/api/general.md +++ b/docs/api/general.md @@ -196,6 +196,19 @@ curl -X GET http://coder-server:8080/api/v2/deployment/config \ "disable_password_auth": true, "disable_path_apps": true, "disable_session_expiry_refresh": true, + "docs_url": { + "forceQuery": true, + "fragment": "string", + "host": "string", + "omitHost": true, + "opaque": "string", + "path": "string", + "rawFragment": "string", + "rawPath": "string", + "rawQuery": "string", + "scheme": "string", + "user": {} + }, "enable_terraform_debug_mode": true, "experiments": ["string"], "git_auth": { diff --git a/docs/api/schemas.md b/docs/api/schemas.md index 26d660425b297..51fe80fdab213 100644 --- a/docs/api/schemas.md +++ b/docs/api/schemas.md @@ -1902,6 +1902,19 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in "disable_password_auth": true, "disable_path_apps": true, "disable_session_expiry_refresh": true, + "docs_url": { + "forceQuery": true, + "fragment": "string", + "host": "string", + "omitHost": true, + "opaque": "string", + "path": "string", + "rawFragment": "string", + "rawPath": "string", + "rawQuery": "string", + "scheme": "string", + "user": {} + }, "enable_terraform_debug_mode": true, "experiments": ["string"], "git_auth": { @@ -2239,6 +2252,19 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in "disable_password_auth": true, "disable_path_apps": true, "disable_session_expiry_refresh": true, + "docs_url": { + "forceQuery": true, + "fragment": "string", + "host": "string", + "omitHost": true, + "opaque": "string", + "path": "string", + "rawFragment": "string", + "rawPath": "string", + "rawQuery": "string", + "scheme": "string", + "user": {} + }, "enable_terraform_debug_mode": true, "experiments": ["string"], "git_auth": { @@ -2438,6 +2464,7 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in | `disable_password_auth` | boolean | false | | | | `disable_path_apps` | boolean | false | | | | `disable_session_expiry_refresh` | boolean | false | | | +| `docs_url` | [clibase.URL](#clibaseurl) | false | | | | `enable_terraform_debug_mode` | boolean | false | | | | `experiments` | array of string | false | | | | `git_auth` | [clibase.Struct-array_codersdk_GitAuthConfig](#clibasestruct-array_codersdk_gitauthconfig) | false | | | diff --git a/docs/cli/server.md b/docs/cli/server.md index ef3db56cd6314..10ce138ea4d4c 100644 --- a/docs/cli/server.md +++ b/docs/cli/server.md @@ -223,6 +223,16 @@ Disable workspace apps that are not served from subdomains. Path-based apps can Disable automatic session expiry bumping due to activity. This forces all sessions to become invalid after the session expiry duration has been reached. +### --docs-url + +| | | +| ----------- | ------------------------------- | +| Type | url | +| Environment | $CODER_DOCS_URL | +| YAML | networking.docsURL | + +Specifies the custom docs URL. + ### --enable-terraform-debug-mode | | | diff --git a/enterprise/cli/testdata/coder_server_--help.golden b/enterprise/cli/testdata/coder_server_--help.golden index d09060409c034..66bd33d96b5c9 100644 --- a/enterprise/cli/testdata/coder_server_--help.golden +++ b/enterprise/cli/testdata/coder_server_--help.golden @@ -128,6 +128,9 @@ Use a YAML configuration file when your server launch become unwieldy. --access-url url, $CODER_ACCESS_URL The URL that users will use to access the Coder deployment. + --docs-url url, $CODER_DOCS_URL + Specifies the custom docs URL. + --proxy-trusted-headers string-array, $CODER_PROXY_TRUSTED_HEADERS Headers to trust for forwarding IP addresses. e.g. Cf-Connecting-Ip, True-Client-Ip, X-Forwarded-For. diff --git a/site/src/api/typesGenerated.ts b/site/src/api/typesGenerated.ts index 64bf215dfd997..26ca40b60aad4 100644 --- a/site/src/api/typesGenerated.ts +++ b/site/src/api/typesGenerated.ts @@ -332,6 +332,7 @@ export interface DeploymentValues { readonly verbose?: boolean readonly access_url?: string readonly wildcard_access_url?: string + readonly docs_url?: string readonly redirect_to_access_url?: boolean readonly http_address?: string readonly autobuild_poll_interval?: number