From a31d47416d184d313244c75863fecf43468bb668 Mon Sep 17 00:00:00 2001 From: Spike Curtis Date: Wed, 6 Dec 2023 14:40:53 +0400 Subject: [PATCH] feat: include server agent API version in buildinfo --- coderd/apidoc/docs.go | 4 ++++ coderd/apidoc/swagger.json | 4 ++++ coderd/deployment.go | 9 +++++---- codersdk/deployment.go | 4 ++++ docs/api/general.md | 1 + docs/api/schemas.md | 14 ++++++++------ enterprise/wsproxy/wsproxy.go | 9 +++++---- site/src/api/typesGenerated.ts | 1 + site/src/testHelpers/entities.ts | 1 + 9 files changed, 33 insertions(+), 14 deletions(-) diff --git a/coderd/apidoc/docs.go b/coderd/apidoc/docs.go index 8b9a47c224549..778e5816a39d2 100644 --- a/coderd/apidoc/docs.go +++ b/coderd/apidoc/docs.go @@ -7827,6 +7827,10 @@ const docTemplate = `{ "codersdk.BuildInfoResponse": { "type": "object", "properties": { + "agent_api_version": { + "description": "AgentAPIVersion is the current version of the Agent API (back versions\nMAY still be supported).", + "type": "string" + }, "dashboard_url": { "description": "DashboardURL is the URL to hit the deployment's dashboard.\nFor external workspace proxies, this is the coderd they are connected\nto.", "type": "string" diff --git a/coderd/apidoc/swagger.json b/coderd/apidoc/swagger.json index 85fe382918ec4..937457dd937f9 100644 --- a/coderd/apidoc/swagger.json +++ b/coderd/apidoc/swagger.json @@ -6970,6 +6970,10 @@ "codersdk.BuildInfoResponse": { "type": "object", "properties": { + "agent_api_version": { + "description": "AgentAPIVersion is the current version of the Agent API (back versions\nMAY still be supported).", + "type": "string" + }, "dashboard_url": { "description": "DashboardURL is the URL to hit the deployment's dashboard.\nFor external workspace proxies, this is the coderd they are connected\nto.", "type": "string" diff --git a/coderd/deployment.go b/coderd/deployment.go index ebea5625583cd..af6955cef0828 100644 --- a/coderd/deployment.go +++ b/coderd/deployment.go @@ -71,10 +71,11 @@ func (api *API) deploymentStats(rw http.ResponseWriter, r *http.Request) { func buildInfo(accessURL *url.URL) http.HandlerFunc { return func(rw http.ResponseWriter, r *http.Request) { httpapi.Write(r.Context(), rw, http.StatusOK, codersdk.BuildInfoResponse{ - ExternalURL: buildinfo.ExternalURL(), - Version: buildinfo.Version(), - DashboardURL: accessURL.String(), - WorkspaceProxy: false, + ExternalURL: buildinfo.ExternalURL(), + Version: buildinfo.Version(), + AgentAPIVersion: AgentAPIVersionREST, + DashboardURL: accessURL.String(), + WorkspaceProxy: false, }) } } diff --git a/codersdk/deployment.go b/codersdk/deployment.go index 56dd5b38f0c8d..e818c91d7f082 100644 --- a/codersdk/deployment.go +++ b/codersdk/deployment.go @@ -2003,6 +2003,10 @@ type BuildInfoResponse struct { DashboardURL string `json:"dashboard_url"` WorkspaceProxy bool `json:"workspace_proxy"` + + // AgentAPIVersion is the current version of the Agent API (back versions + // MAY still be supported). + AgentAPIVersion string `json:"agent_api_version"` } type WorkspaceProxyBuildInfo struct { diff --git a/docs/api/general.md b/docs/api/general.md index de89e07e558c5..f5e1493db3462 100644 --- a/docs/api/general.md +++ b/docs/api/general.md @@ -53,6 +53,7 @@ curl -X GET http://coder-server:8080/api/v2/buildinfo \ ```json { + "agent_api_version": "string", "dashboard_url": "string", "external_url": "string", "version": "string", diff --git a/docs/api/schemas.md b/docs/api/schemas.md index bcf54626d4952..1c113d3f919e4 100644 --- a/docs/api/schemas.md +++ b/docs/api/schemas.md @@ -1430,6 +1430,7 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in ```json { + "agent_api_version": "string", "dashboard_url": "string", "external_url": "string", "version": "string", @@ -1439,12 +1440,13 @@ AuthorizationObject can represent a "set" of objects, such as: all workspaces in ### Properties -| Name | Type | Required | Restrictions | Description | -| ----------------- | ------- | -------- | ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `dashboard_url` | string | false | | Dashboard URL is the URL to hit the deployment's dashboard. For external workspace proxies, this is the coderd they are connected to. | -| `external_url` | string | false | | External URL references the current Coder version. For production builds, this will link directly to a release. For development builds, this will link to a commit. | -| `version` | string | false | | Version returns the semantic version of the build. | -| `workspace_proxy` | boolean | false | | | +| Name | Type | Required | Restrictions | Description | +| ------------------- | ------- | -------- | ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `agent_api_version` | string | false | | Agent api version is the current version of the Agent API (back versions MAY still be supported). | +| `dashboard_url` | string | false | | Dashboard URL is the URL to hit the deployment's dashboard. For external workspace proxies, this is the coderd they are connected to. | +| `external_url` | string | false | | External URL references the current Coder version. For production builds, this will link directly to a release. For development builds, this will link to a commit. | +| `version` | string | false | | Version returns the semantic version of the build. | +| `workspace_proxy` | boolean | false | | | ## codersdk.BuildReason diff --git a/enterprise/wsproxy/wsproxy.go b/enterprise/wsproxy/wsproxy.go index d83f760c8fc7c..d626a7ea51cdd 100644 --- a/enterprise/wsproxy/wsproxy.go +++ b/enterprise/wsproxy/wsproxy.go @@ -475,10 +475,11 @@ func (s *Server) DialCoordinator(ctx context.Context) (tailnet.MultiAgentConn, e func (s *Server) buildInfo(rw http.ResponseWriter, r *http.Request) { httpapi.Write(r.Context(), rw, http.StatusOK, codersdk.BuildInfoResponse{ - ExternalURL: buildinfo.ExternalURL(), - Version: buildinfo.Version(), - DashboardURL: s.DashboardURL.String(), - WorkspaceProxy: true, + ExternalURL: buildinfo.ExternalURL(), + Version: buildinfo.Version(), + AgentAPIVersion: coderd.AgentAPIVersionREST, + DashboardURL: s.DashboardURL.String(), + WorkspaceProxy: true, }) } diff --git a/site/src/api/typesGenerated.ts b/site/src/api/typesGenerated.ts index af34c7d602e4e..21b27ddf8a61c 100644 --- a/site/src/api/typesGenerated.ts +++ b/site/src/api/typesGenerated.ts @@ -162,6 +162,7 @@ export interface BuildInfoResponse { readonly version: string; readonly dashboard_url: string; readonly workspace_proxy: boolean; + readonly agent_api_version: string; } // From codersdk/insights.go diff --git a/site/src/testHelpers/entities.ts b/site/src/testHelpers/entities.ts index f9dc9f6e558b6..bab25c74e7ff7 100644 --- a/site/src/testHelpers/entities.ts +++ b/site/src/testHelpers/entities.ts @@ -194,6 +194,7 @@ export const MockProxyLatencies: Record = { }; export const MockBuildInfo: TypesGen.BuildInfoResponse = { + agent_api_version: "2.1", external_url: "file:///mock-url", version: "v99.999.9999+c9cdf14", dashboard_url: "https:///mock-url",