Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit37b0aaa

Browse files
authored
fix: add workspace option 'deleted' to options type (#2095)
* fix: add workspace option 'deleted' to options type* dead code
1 parent367897e commit37b0aaa

File tree

5 files changed

+32
-23
lines changed

5 files changed

+32
-23
lines changed

‎coderd/workspaces.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,6 @@ func (api *API) workspace(rw http.ResponseWriter, r *http.Request) {
6060
})
6161
return
6262
}
63-
if!workspace.Deleted&&showDeleted {
64-
httpapi.Write(rw,http.StatusBadRequest, httpapi.Response{
65-
Message:fmt.Sprintf("Workspace %q is not deleted, please remove '?deleted=true' and try again",workspace.ID.String()),
66-
})
67-
return
68-
}
6963

7064
build,err:=api.Database.GetLatestWorkspaceBuildByWorkspaceID(r.Context(),workspace.ID)
7165
iferr!=nil {

‎coderd/workspaces_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,9 @@ func TestWorkspace(t *testing.T) {
4646
workspace:=coderdtest.CreateWorkspace(t,client,user.OrganizationID,template.ID)
4747
coderdtest.AwaitWorkspaceBuildJob(t,client,workspace.LatestBuild.ID)
4848

49-
// Getting with deleted=true shouldfail.
49+
// Getting with deleted=true shouldstill work.
5050
_,err:=client.DeletedWorkspace(context.Background(),workspace.ID)
51-
require.Error(t,err)
52-
require.ErrorContains(t,err,"400")// bad request
51+
require.NoError(t,err)
5352

5453
// Delete the workspace
5554
build,err:=client.CreateWorkspaceBuild(context.Background(),workspace.ID, codersdk.CreateWorkspaceBuildRequest{

‎codersdk/client.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,6 @@ type Client struct {
3636

3737
typerequestOptionfunc(*http.Request)
3838

39-
funcqueryParam(k,vstring)requestOption {
40-
returnfunc(r*http.Request) {
41-
q:=r.URL.Query()
42-
q.Set(k,v)
43-
r.URL.RawQuery=q.Encode()
44-
}
45-
}
46-
4739
// Request performs an HTTP request with the body provided.
4840
// The caller is responsible for closing the response body.
4941
func (c*Client)Request(ctx context.Context,method,pathstring,bodyinterface{},opts...requestOption) (*http.Response,error) {

‎codersdk/workspaces.go

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,33 @@ type CreateWorkspaceBuildRequest struct {
3838
ProvisionerState []byte`json:"state,omitempty"`
3939
}
4040

41+
typeWorkspaceOptionsstruct {
42+
Deletedbool`json:"deleted,omitempty"`
43+
}
44+
45+
// asRequestOption returns a function that can be used in (*Client).Request.
46+
// It modifies the request query parameters.
47+
func (oWorkspaceOptions)asRequestOption()requestOption {
48+
returnfunc(r*http.Request) {
49+
q:=r.URL.Query()
50+
ifo.Deleted {
51+
q.Set("deleted","true")
52+
}
53+
r.URL.RawQuery=q.Encode()
54+
}
55+
}
56+
4157
// Workspace returns a single workspace.
4258
func (c*Client)Workspace(ctx context.Context,id uuid.UUID) (Workspace,error) {
4359
returnc.getWorkspace(ctx,id)
4460
}
4561

4662
// DeletedWorkspace returns a single workspace that was deleted.
4763
func (c*Client)DeletedWorkspace(ctx context.Context,id uuid.UUID) (Workspace,error) {
48-
returnc.getWorkspace(ctx,id,queryParam("deleted","true"))
64+
o:=WorkspaceOptions{
65+
Deleted:true,
66+
}
67+
returnc.getWorkspace(ctx,id,o.asRequestOption())
4968
}
5069

5170
func (c*Client)getWorkspace(ctx context.Context,id uuid.UUID,opts...requestOption) (Workspace,error) {

‎site/src/api/typesGenerated.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ export interface ProvisionerJobLog {
221221
readonlyoutput:string
222222
}
223223

224-
// From codersdk/workspaces.go:182:6
224+
// From codersdk/workspaces.go:201:6
225225
exportinterfacePutExtendWorkspaceRequest{
226226
readonlydeadline:string
227227
}
@@ -298,12 +298,12 @@ export interface UpdateUserProfileRequest {
298298
readonlyusername:string
299299
}
300300

301-
// From codersdk/workspaces.go:141:6
301+
// From codersdk/workspaces.go:160:6
302302
exportinterfaceUpdateWorkspaceAutostartRequest{
303303
readonlyschedule?:string
304304
}
305305

306-
// From codersdk/workspaces.go:161:6
306+
// From codersdk/workspaces.go:180:6
307307
exportinterfaceUpdateWorkspaceTTLRequest{
308308
readonlyttl_ms?:number
309309
}
@@ -445,18 +445,23 @@ export interface WorkspaceBuild {
445445
readonlydeadline:string
446446
}
447447

448-
// From codersdk/workspaces.go:64:6
448+
// From codersdk/workspaces.go:83:6
449449
exportinterfaceWorkspaceBuildsRequestextendsPagination{
450450
readonlyWorkspaceID:string
451451
}
452452

453-
// From codersdk/workspaces.go:200:6
453+
// From codersdk/workspaces.go:219:6
454454
exportinterfaceWorkspaceFilter{
455455
readonlyorganization_id?:string
456456
readonlyowner?:string
457457
readonlyname?:string
458458
}
459459

460+
// From codersdk/workspaces.go:41:6
461+
exportinterfaceWorkspaceOptions{
462+
readonlydeleted?:boolean
463+
}
464+
460465
// From codersdk/workspaceresources.go:21:6
461466
exportinterfaceWorkspaceResource{
462467
readonlyid:string

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp