Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 975a32c

Browse files
committed
chore(codersdk): deprecate unused WorkspaceAppStatus fields
1 parent e54aa44 commit 975a32c

21 files changed

+119
-129
lines changed

coderd/apidoc/docs.go

+4-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/apidoc/swagger.json

+4-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/db2sdk/db2sdk.go

+8-10
Original file line numberDiff line numberDiff line change
@@ -537,16 +537,14 @@ func WorkspaceAppStatuses(statuses []database.WorkspaceAppStatus) []codersdk.Wor
537537

538538
func WorkspaceAppStatus(status database.WorkspaceAppStatus) codersdk.WorkspaceAppStatus {
539539
return codersdk.WorkspaceAppStatus{
540-
ID: status.ID,
541-
CreatedAt: status.CreatedAt,
542-
WorkspaceID: status.WorkspaceID,
543-
AgentID: status.AgentID,
544-
AppID: status.AppID,
545-
NeedsUserAttention: status.NeedsUserAttention,
546-
URI: status.Uri.String,
547-
Icon: status.Icon.String,
548-
Message: status.Message,
549-
State: codersdk.WorkspaceAppStatusState(status.State),
540+
ID: status.ID,
541+
CreatedAt: status.CreatedAt,
542+
WorkspaceID: status.WorkspaceID,
543+
AgentID: status.AgentID,
544+
AppID: status.AppID,
545+
URI: status.Uri.String,
546+
Message: status.Message,
547+
State: codersdk.WorkspaceAppStatusState(status.State),
550548
}
551549
}
552550

coderd/database/dbmem/dbmem.go

+8-10
Original file line numberDiff line numberDiff line change
@@ -9764,16 +9764,14 @@ func (q *FakeQuerier) InsertWorkspaceAppStatus(_ context.Context, arg database.I
97649764
defer q.mutex.Unlock()
97659765

97669766
status := database.WorkspaceAppStatus{
9767-
ID: arg.ID,
9768-
CreatedAt: arg.CreatedAt,
9769-
WorkspaceID: arg.WorkspaceID,
9770-
AgentID: arg.AgentID,
9771-
AppID: arg.AppID,
9772-
NeedsUserAttention: arg.NeedsUserAttention,
9773-
State: arg.State,
9774-
Message: arg.Message,
9775-
Uri: arg.Uri,
9776-
Icon: arg.Icon,
9767+
ID: arg.ID,
9768+
CreatedAt: arg.CreatedAt,
9769+
WorkspaceID: arg.WorkspaceID,
9770+
AgentID: arg.AgentID,
9771+
AppID: arg.AppID,
9772+
State: arg.State,
9773+
Message: arg.Message,
9774+
Uri: arg.Uri,
97779775
}
97789776
q.workspaceAppStatuses = append(q.workspaceAppStatuses, status)
97799777
return status, nil

coderd/database/dump.sql

+1-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ALTER TABLE ONLY workspace_app_statuses
2+
ADD COLUMN IF NOT EXISTS needs_user_attention BOOLEAN NOT NULL DEFAULT FALSE,
3+
ADD COLUMN IF NOT EXISTS icon TEXT;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ALTER TABLE ONLY workspace_app_statuses
2+
DROP COLUMN IF EXISTS needs_user_attention,
3+
DROP COLUMN IF EXISTS icon;

coderd/database/models.go

+8-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/queries.sql.go

+14-24
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/queries/workspaceapps.sql

+3-3
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ WHERE
4444
id = $1;
4545

4646
-- name: InsertWorkspaceAppStatus :one
47-
INSERT INTO workspace_app_statuses (id, created_at, workspace_id, agent_id, app_id, state, message, needs_user_attention, uri, icon)
48-
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)
47+
INSERT INTO workspace_app_statuses (id, created_at, workspace_id, agent_id, app_id, state, message, uri)
48+
VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
4949
RETURNING *;
5050

5151
-- name: GetWorkspaceAppStatusesByAppIDs :many
@@ -54,6 +54,6 @@ SELECT * FROM workspace_app_statuses WHERE app_id = ANY(@ids :: uuid [ ]);
5454
-- name: GetLatestWorkspaceAppStatusesByWorkspaceIDs :many
5555
SELECT DISTINCT ON (workspace_id)
5656
*
57-
FROM workspace_app_statuses
57+
FROM workspace_app_statuses
5858
WHERE workspace_id = ANY(@ids :: uuid[])
5959
ORDER BY workspace_id, created_at DESC;

coderd/workspaceagents.go

-5
Original file line numberDiff line numberDiff line change
@@ -366,11 +366,6 @@ func (api *API) patchWorkspaceAgentAppStatus(rw http.ResponseWriter, r *http.Req
366366
String: req.URI,
367367
Valid: req.URI != "",
368368
},
369-
Icon: sql.NullString{
370-
String: req.Icon,
371-
Valid: req.Icon != "",
372-
},
373-
NeedsUserAttention: req.NeedsUserAttention,
374369
})
375370
if err != nil {
376371
httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{

coderd/workspaceagents_test.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -366,8 +366,10 @@ func TestWorkspaceAgentAppStatus(t *testing.T) {
366366
AppSlug: "vscode",
367367
Message: "testing",
368368
URI: "https://example.com",
369-
Icon: "https://example.com/icon.png",
370369
State: codersdk.WorkspaceAppStatusStateComplete,
370+
// Ensure deprecated fields are ignored.
371+
Icon: "https://example.com/icon.png",
372+
NeedsUserAttention: true,
371373
})
372374
require.NoError(t, err)
373375

@@ -376,6 +378,9 @@ func TestWorkspaceAgentAppStatus(t *testing.T) {
376378
agent, err := client.WorkspaceAgent(ctx, workspace.LatestBuild.Resources[0].Agents[0].ID)
377379
require.NoError(t, err)
378380
require.Len(t, agent.Apps[0].Statuses, 1)
381+
// Deprecated fields should be ignored.
382+
require.Empty(t, agent.Apps[0].Statuses[0].Icon)
383+
require.False(t, agent.Apps[0].Statuses[0].NeedsUserAttention)
379384
})
380385
}
381386

codersdk/agentsdk/agentsdk.go

+8-6
Original file line numberDiff line numberDiff line change
@@ -583,12 +583,14 @@ func (c *Client) PatchLogs(ctx context.Context, req PatchLogs) error {
583583

584584
// PatchAppStatus updates the status of a workspace app.
585585
type PatchAppStatus struct {
586-
AppSlug string `json:"app_slug"`
587-
NeedsUserAttention bool `json:"needs_user_attention"`
588-
State codersdk.WorkspaceAppStatusState `json:"state"`
589-
Message string `json:"message"`
590-
URI string `json:"uri"`
591-
Icon string `json:"icon"`
586+
AppSlug string `json:"app_slug"`
587+
State codersdk.WorkspaceAppStatusState `json:"state"`
588+
Message string `json:"message"`
589+
URI string `json:"uri"`
590+
// Deprecated: this field is unused and will be removed in a future version.
591+
Icon string `json:"icon"`
592+
// Deprecated: this field is unused and will be removed in a future version.
593+
NeedsUserAttention bool `json:"needs_user_attention"`
592594
}
593595

594596
func (c *Client) PatchAppStatus(ctx context.Context, req PatchAppStatus) error {

codersdk/toolsdk/toolsdk.go

+5-15
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,6 @@ var (
6767
"type": "string",
6868
"description": "A link to a relevant resource, such as a PR or issue.",
6969
},
70-
"emoji": map[string]any{
71-
"type": "string",
72-
"description": "An emoji that visually represents your current progress. Choose an emoji that helps the user understand your current status at a glance.",
73-
},
7470
"state": map[string]any{
7571
"type": "string",
7672
"description": "The state of your task. This can be one of the following: working, complete, or failure. Select the state that best represents your current progress.",
@@ -81,7 +77,7 @@ var (
8177
},
8278
},
8379
},
84-
Required: []string{"summary", "link", "emoji", "state"},
80+
Required: []string{"summary", "link", "state"},
8581
},
8682
},
8783
Handler: func(ctx context.Context, args map[string]any) (string, error) {
@@ -104,22 +100,16 @@ var (
104100
if !ok {
105101
return "", xerrors.New("link must be a string")
106102
}
107-
emoji, ok := args["emoji"].(string)
108-
if !ok {
109-
return "", xerrors.New("emoji must be a string")
110-
}
111103
state, ok := args["state"].(string)
112104
if !ok {
113105
return "", xerrors.New("state must be a string")
114106
}
115107

116108
if err := agentClient.PatchAppStatus(ctx, agentsdk.PatchAppStatus{
117-
AppSlug: appSlug,
118-
Message: summary,
119-
URI: link,
120-
Icon: emoji,
121-
NeedsUserAttention: false, // deprecated, to be removed later
122-
State: codersdk.WorkspaceAppStatusState(state),
109+
AppSlug: appSlug,
110+
Message: summary,
111+
URI: link,
112+
State: codersdk.WorkspaceAppStatusState(state),
123113
}); err != nil {
124114
return "", err
125115
}

codersdk/toolsdk/toolsdk_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ func TestTools(t *testing.T) {
7575
"summary": "test summary",
7676
"state": "complete",
7777
"link": "https://example.com",
78-
"emoji": "✅",
7978
})
8079
require.NoError(t, err)
8180
})

0 commit comments

Comments
 (0)