feat: add workspace_id, owner_name to agent manifest (#10199)

Co-authored-by: Kyle Carberry <kyle@carberry.com>
Co-authored-by: Atif Ali <atif@coder.com>
This commit is contained in:
Szabolcs Fruhwald
2023-12-03 13:41:54 -08:00
committed by GitHub
parent 28eca2e53f
commit baf3bf6b9c
7 changed files with 46 additions and 17 deletions

7
coderd/apidoc/docs.go generated
View File

@ -6917,6 +6917,10 @@ const docTemplate = `{
"motd_file": { "motd_file": {
"type": "string" "type": "string"
}, },
"owner_name": {
"description": "OwnerName and WorkspaceID are used by an open-source user to identify the workspace.\nWe do not provide insurance that this will not be removed in the future,\nbut if it's easy to persist lets keep it around.",
"type": "string"
},
"scripts": { "scripts": {
"type": "array", "type": "array",
"items": { "items": {
@ -6925,6 +6929,9 @@ const docTemplate = `{
}, },
"vscode_port_proxy_uri": { "vscode_port_proxy_uri": {
"type": "string" "type": "string"
},
"workspace_id": {
"type": "string"
} }
} }
}, },

View File

@ -6103,6 +6103,10 @@
"motd_file": { "motd_file": {
"type": "string" "type": "string"
}, },
"owner_name": {
"description": "OwnerName and WorkspaceID are used by an open-source user to identify the workspace.\nWe do not provide insurance that this will not be removed in the future,\nbut if it's easy to persist lets keep it around.",
"type": "string"
},
"scripts": { "scripts": {
"type": "array", "type": "array",
"items": { "items": {
@ -6111,6 +6115,9 @@
}, },
"vscode_port_proxy_uri": { "vscode_port_proxy_uri": {
"type": "string" "type": "string"
},
"workspace_id": {
"type": "string"
} }
} }
}, },

View File

@ -237,6 +237,8 @@ func (api *API) workspaceAgentManifest(rw http.ResponseWriter, r *http.Request)
httpapi.Write(ctx, rw, http.StatusOK, agentsdk.Manifest{ httpapi.Write(ctx, rw, http.StatusOK, agentsdk.Manifest{
AgentID: apiAgent.ID, AgentID: apiAgent.ID,
OwnerName: owner.Username,
WorkspaceID: workspace.ID,
Apps: convertApps(dbApps, workspaceAgent, owner.Username, workspace), Apps: convertApps(dbApps, workspaceAgent, owner.Username, workspace),
Scripts: convertScripts(scripts), Scripts: convertScripts(scripts),
DERPMap: api.DERPMap(), DERPMap: api.DERPMap(),

View File

@ -998,6 +998,8 @@ func TestWorkspaceAgent_Metadata(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
// Verify manifest API response. // Verify manifest API response.
require.Equal(t, workspace.ID, manifest.WorkspaceID)
require.Equal(t, workspace.OwnerName, manifest.OwnerName)
require.Equal(t, "First Meta", manifest.Metadata[0].DisplayName) require.Equal(t, "First Meta", manifest.Metadata[0].DisplayName)
require.Equal(t, "foo1", manifest.Metadata[0].Key) require.Equal(t, "foo1", manifest.Metadata[0].Key)
require.Equal(t, "echo hi", manifest.Metadata[0].Script) require.Equal(t, "echo hi", manifest.Metadata[0].Script)

View File

@ -98,6 +98,11 @@ func (c *Client) PostMetadata(ctx context.Context, req PostMetadataRequest) erro
type Manifest struct { type Manifest struct {
AgentID uuid.UUID `json:"agent_id"` AgentID uuid.UUID `json:"agent_id"`
// OwnerName and WorkspaceID are used by an open-source user to identify the workspace.
// We do not provide insurance that this will not be removed in the future,
// but if it's easy to persist lets keep it around.
OwnerName string `json:"owner_name"`
WorkspaceID uuid.UUID `json:"workspace_id"`
// GitAuthConfigs stores the number of Git configurations // GitAuthConfigs stores the number of Git configurations
// the Coder deployment has. If this number is >0, we // the Coder deployment has. If this number is >0, we
// set up special configuration in the workspace. // set up special configuration in the workspace.

4
docs/api/agents.md generated
View File

@ -518,6 +518,7 @@ curl -X GET http://coder-server:8080/api/v2/workspaceagents/me/manifest \
} }
], ],
"motd_file": "string", "motd_file": "string",
"owner_name": "string",
"scripts": [ "scripts": [
{ {
"cron": "string", "cron": "string",
@ -530,7 +531,8 @@ curl -X GET http://coder-server:8080/api/v2/workspaceagents/me/manifest \
"timeout": 0 "timeout": 0
} }
], ],
"vscode_port_proxy_uri": "string" "vscode_port_proxy_uri": "string",
"workspace_id": "string"
} }
``` ```

36
docs/api/schemas.md generated
View File

@ -283,6 +283,7 @@
} }
], ],
"motd_file": "string", "motd_file": "string",
"owner_name": "string",
"scripts": [ "scripts": [
{ {
"cron": "string", "cron": "string",
@ -295,27 +296,30 @@
"timeout": 0 "timeout": 0
} }
], ],
"vscode_port_proxy_uri": "string" "vscode_port_proxy_uri": "string",
"workspace_id": "string"
} }
``` ```
### Properties ### Properties
| Name | Type | Required | Restrictions | Description | | Name | Type | Required | Restrictions | Description |
| ---------------------------- | ------------------------------------------------------------------------------------------------- | -------- | ------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------- | | ---------------------------- | ------------------------------------------------------------------------------------------------- | -------- | ------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `agent_id` | string | false | | | | `agent_id` | string | false | | |
| `apps` | array of [codersdk.WorkspaceApp](#codersdkworkspaceapp) | false | | | | `apps` | array of [codersdk.WorkspaceApp](#codersdkworkspaceapp) | false | | |
| `derp_force_websockets` | boolean | false | | | | `derp_force_websockets` | boolean | false | | |
| `derpmap` | [tailcfg.DERPMap](#tailcfgderpmap) | false | | | | `derpmap` | [tailcfg.DERPMap](#tailcfgderpmap) | false | | |
| `directory` | string | false | | | | `directory` | string | false | | |
| `disable_direct_connections` | boolean | false | | | | `disable_direct_connections` | boolean | false | | |
| `environment_variables` | object | false | | | | `environment_variables` | object | false | | |
| » `[any property]` | string | false | | | | » `[any property]` | string | false | | |
| `git_auth_configs` | integer | false | | Git auth configs stores the number of Git configurations the Coder deployment has. If this number is >0, we set up special configuration in the workspace. | | `git_auth_configs` | integer | false | | Git auth configs stores the number of Git configurations the Coder deployment has. If this number is >0, we set up special configuration in the workspace. |
| `metadata` | array of [codersdk.WorkspaceAgentMetadataDescription](#codersdkworkspaceagentmetadatadescription) | false | | | | `metadata` | array of [codersdk.WorkspaceAgentMetadataDescription](#codersdkworkspaceagentmetadatadescription) | false | | |
| `motd_file` | string | false | | | | `motd_file` | string | false | | |
| `scripts` | array of [codersdk.WorkspaceAgentScript](#codersdkworkspaceagentscript) | false | | | | `owner_name` | string | false | | Owner name and WorkspaceID are used by an open-source user to identify the workspace. We do not provide insurance that this will not be removed in the future, but if it's easy to persist lets keep it around. |
| `vscode_port_proxy_uri` | string | false | | | | `scripts` | array of [codersdk.WorkspaceAgentScript](#codersdkworkspaceagentscript) | false | | |
| `vscode_port_proxy_uri` | string | false | | |
| `workspace_id` | string | false | | |
## agentsdk.Metadata ## agentsdk.Metadata