Skip to content

Commit 415efb7

Browse files
committed
add and populate the module_path column to workspace_resources
1 parent 0017e26 commit 415efb7

File tree

15 files changed

+301
-247
lines changed

15 files changed

+301
-247
lines changed

coderd/database/dbgen/dbgen.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,10 @@ func WorkspaceResource(t testing.TB, db database.Store, orig database.WorkspaceR
657657
Valid: takeFirst(orig.InstanceType.Valid, false),
658658
},
659659
DailyCost: takeFirst(orig.DailyCost, 0),
660+
ModulePath: sql.NullString{
661+
String: takeFirst(orig.ModulePath.String, ""),
662+
Valid: takeFirst(orig.ModulePath.Valid, true),
663+
},
660664
})
661665
require.NoError(t, err, "insert resource")
662666
return resource

coderd/database/dump.sql

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/gen/dump/main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,11 @@ func main() {
3737
}
3838
}()
3939

40-
connection, err := dbtestutil.Open(t)
40+
connection, cleanup, err := dbtestutil.OpenContainerized(t, dbtestutil.DBContainerOptions{})
4141
if err != nil {
4242
panic(err)
4343
}
44+
defer cleanup()
4445

4546
db, err := sql.Open("postgres", connection)
4647
if err != nil {

coderd/database/migrations/000274_workspace_modules.down.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ DROP TABLE workspace_modules;
22

33
ALTER TABLE
44
workspace_resources
5-
DROP COLUMN module;
5+
DROP COLUMN module_path;

coderd/database/migrations/000274_workspace_modules.up.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
ALTER TABLE
22
workspace_resources
33
ADD
4-
COLUMN module TEXT;
4+
COLUMN module_path TEXT;
55

66
CREATE TABLE workspace_modules (
77
id uuid NOT NULL,

coderd/database/models.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/queries.sql.go

Lines changed: 13 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/queries/workspaceresources.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ SELECT * FROM workspace_resources WHERE created_at > $1;
2727

2828
-- name: InsertWorkspaceResource :one
2929
INSERT INTO
30-
workspace_resources (id, created_at, job_id, transition, type, name, hide, icon, instance_type, daily_cost)
30+
workspace_resources (id, created_at, job_id, transition, type, name, hide, icon, instance_type, daily_cost, module_path)
3131
VALUES
32-
($1, $2, $3, $4, $5, $6, $7, $8, $9, $10) RETURNING *;
32+
($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11) RETURNING *;
3333

3434
-- name: GetWorkspaceResourceMetadataByResourceIDs :many
3535
SELECT

coderd/provisionerdserver/provisionerdserver.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1799,6 +1799,11 @@ func InsertWorkspaceResource(ctx context.Context, db database.Store, jobID uuid.
17991799
String: protoResource.InstanceType,
18001800
Valid: protoResource.InstanceType != "",
18011801
},
1802+
ModulePath: sql.NullString{
1803+
String: protoResource.ModulePath,
1804+
// empty string is root module
1805+
Valid: true,
1806+
},
18021807
})
18031808
if err != nil {
18041809
return xerrors.Errorf("insert provisioner job resource %q: %w", protoResource.Name, err)

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,7 @@ require (
344344
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
345345
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 // indirect
346346
github.com/hashicorp/go-hclog v1.6.3 // indirect
347+
github.com/hashicorp/go-terraform-address v0.0.0-20240523040243-ccea9d309e0c
347348
github.com/hashicorp/go-uuid v1.0.3 // indirect
348349
github.com/hashicorp/hcl v1.0.1-vault-5 // indirect
349350
github.com/hashicorp/hcl/v2 v2.22.0

0 commit comments

Comments
 (0)