mirror of
https://github.com/coder/coder.git
synced 2025-07-08 11:39:50 +00:00
feat: Allow hide resources (#3977)
This commit is contained in:
@ -1767,6 +1767,7 @@ func (q *fakeQuerier) InsertWorkspaceResource(_ context.Context, arg database.In
|
||||
Transition: arg.Transition,
|
||||
Type: arg.Type,
|
||||
Name: arg.Name,
|
||||
Hide: arg.Hide,
|
||||
}
|
||||
q.provisionerJobResources = append(q.provisionerJobResources, resource)
|
||||
return resource, nil
|
||||
|
3
coderd/database/dump.sql
generated
3
coderd/database/dump.sql
generated
@ -366,7 +366,8 @@ CREATE TABLE workspace_resources (
|
||||
job_id uuid NOT NULL,
|
||||
transition workspace_transition NOT NULL,
|
||||
type character varying(192) NOT NULL,
|
||||
name character varying(64) NOT NULL
|
||||
name character varying(64) NOT NULL,
|
||||
hide boolean DEFAULT false NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE workspaces (
|
||||
|
@ -0,0 +1,2 @@
|
||||
ALTER TABLE workspace_resources
|
||||
DROP COLUMN hide;
|
@ -0,0 +1,2 @@
|
||||
ALTER TABLE workspace_resources
|
||||
ADD COLUMN hide boolean DEFAULT false NOT NULL;
|
@ -586,6 +586,7 @@ type WorkspaceResource struct {
|
||||
Transition WorkspaceTransition `db:"transition" json:"transition"`
|
||||
Type string `db:"type" json:"type"`
|
||||
Name string `db:"name" json:"name"`
|
||||
Hide bool `db:"hide" json:"hide"`
|
||||
}
|
||||
|
||||
type WorkspaceResourceMetadatum struct {
|
||||
|
@ -4320,7 +4320,7 @@ func (q *sqlQuerier) UpdateWorkspaceBuildByID(ctx context.Context, arg UpdateWor
|
||||
|
||||
const getWorkspaceResourceByID = `-- name: GetWorkspaceResourceByID :one
|
||||
SELECT
|
||||
id, created_at, job_id, transition, type, name
|
||||
id, created_at, job_id, transition, type, name, hide
|
||||
FROM
|
||||
workspace_resources
|
||||
WHERE
|
||||
@ -4337,6 +4337,7 @@ func (q *sqlQuerier) GetWorkspaceResourceByID(ctx context.Context, id uuid.UUID)
|
||||
&i.Transition,
|
||||
&i.Type,
|
||||
&i.Name,
|
||||
&i.Hide,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
@ -4451,7 +4452,7 @@ func (q *sqlQuerier) GetWorkspaceResourceMetadataCreatedAfter(ctx context.Contex
|
||||
|
||||
const getWorkspaceResourcesByJobID = `-- name: GetWorkspaceResourcesByJobID :many
|
||||
SELECT
|
||||
id, created_at, job_id, transition, type, name
|
||||
id, created_at, job_id, transition, type, name, hide
|
||||
FROM
|
||||
workspace_resources
|
||||
WHERE
|
||||
@ -4474,6 +4475,7 @@ func (q *sqlQuerier) GetWorkspaceResourcesByJobID(ctx context.Context, jobID uui
|
||||
&i.Transition,
|
||||
&i.Type,
|
||||
&i.Name,
|
||||
&i.Hide,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -4489,7 +4491,7 @@ func (q *sqlQuerier) GetWorkspaceResourcesByJobID(ctx context.Context, jobID uui
|
||||
}
|
||||
|
||||
const getWorkspaceResourcesCreatedAfter = `-- name: GetWorkspaceResourcesCreatedAfter :many
|
||||
SELECT id, created_at, job_id, transition, type, name FROM workspace_resources WHERE created_at > $1
|
||||
SELECT id, created_at, job_id, transition, type, name, hide FROM workspace_resources WHERE created_at > $1
|
||||
`
|
||||
|
||||
func (q *sqlQuerier) GetWorkspaceResourcesCreatedAfter(ctx context.Context, createdAt time.Time) ([]WorkspaceResource, error) {
|
||||
@ -4508,6 +4510,7 @@ func (q *sqlQuerier) GetWorkspaceResourcesCreatedAfter(ctx context.Context, crea
|
||||
&i.Transition,
|
||||
&i.Type,
|
||||
&i.Name,
|
||||
&i.Hide,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -4524,9 +4527,9 @@ func (q *sqlQuerier) GetWorkspaceResourcesCreatedAfter(ctx context.Context, crea
|
||||
|
||||
const insertWorkspaceResource = `-- name: InsertWorkspaceResource :one
|
||||
INSERT INTO
|
||||
workspace_resources (id, created_at, job_id, transition, type, name)
|
||||
workspace_resources (id, created_at, job_id, transition, type, name, hide)
|
||||
VALUES
|
||||
($1, $2, $3, $4, $5, $6) RETURNING id, created_at, job_id, transition, type, name
|
||||
($1, $2, $3, $4, $5, $6, $7) RETURNING id, created_at, job_id, transition, type, name, hide
|
||||
`
|
||||
|
||||
type InsertWorkspaceResourceParams struct {
|
||||
@ -4536,6 +4539,7 @@ type InsertWorkspaceResourceParams struct {
|
||||
Transition WorkspaceTransition `db:"transition" json:"transition"`
|
||||
Type string `db:"type" json:"type"`
|
||||
Name string `db:"name" json:"name"`
|
||||
Hide bool `db:"hide" json:"hide"`
|
||||
}
|
||||
|
||||
func (q *sqlQuerier) InsertWorkspaceResource(ctx context.Context, arg InsertWorkspaceResourceParams) (WorkspaceResource, error) {
|
||||
@ -4546,6 +4550,7 @@ func (q *sqlQuerier) InsertWorkspaceResource(ctx context.Context, arg InsertWork
|
||||
arg.Transition,
|
||||
arg.Type,
|
||||
arg.Name,
|
||||
arg.Hide,
|
||||
)
|
||||
var i WorkspaceResource
|
||||
err := row.Scan(
|
||||
@ -4555,6 +4560,7 @@ func (q *sqlQuerier) InsertWorkspaceResource(ctx context.Context, arg InsertWork
|
||||
&i.Transition,
|
||||
&i.Type,
|
||||
&i.Name,
|
||||
&i.Hide,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
@ -19,9 +19,9 @@ SELECT * FROM workspace_resources WHERE created_at > $1;
|
||||
|
||||
-- name: InsertWorkspaceResource :one
|
||||
INSERT INTO
|
||||
workspace_resources (id, created_at, job_id, transition, type, name)
|
||||
workspace_resources (id, created_at, job_id, transition, type, name, hide)
|
||||
VALUES
|
||||
($1, $2, $3, $4, $5, $6) RETURNING *;
|
||||
($1, $2, $3, $4, $5, $6, $7) RETURNING *;
|
||||
|
||||
-- name: GetWorkspaceResourceMetadataByResourceID :many
|
||||
SELECT
|
||||
|
@ -752,6 +752,7 @@ func insertWorkspaceResource(ctx context.Context, db database.Store, jobID uuid.
|
||||
Transition: transition,
|
||||
Type: protoResource.Type,
|
||||
Name: protoResource.Name,
|
||||
Hide: protoResource.Hide,
|
||||
})
|
||||
if err != nil {
|
||||
return xerrors.Errorf("insert provisioner job resource %q: %w", protoResource.Name, err)
|
||||
|
@ -698,6 +698,7 @@ func convertWorkspaceResource(resource database.WorkspaceResource, agents []code
|
||||
Transition: codersdk.WorkspaceTransition(resource.Transition),
|
||||
Type: resource.Type,
|
||||
Name: resource.Name,
|
||||
Hide: resource.Hide,
|
||||
Agents: agents,
|
||||
Metadata: convertedMetadata,
|
||||
}
|
||||
|
Reference in New Issue
Block a user