Skip to content

Commit 1e83c27

Browse files
committed
Add use permission
1 parent 1f4fb0e commit 1e83c27

File tree

5 files changed

+793
-59
lines changed

5 files changed

+793
-59
lines changed
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
1-
go run ./generate/main.go > objects_tmp.go && mv objects_tmp.go objects.go
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
export SCRIPT_DIR=$(dirname "${BASH_SOURCE[0]}")
6+
cd "$SCRIPT_DIR" && go run ./generate/main.go > objects_tmp.go && mv objects_tmp.go objects.go

coderd/database/spice/policy/playground/relationships/manualobjects.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,11 @@ func AllRelationsToStrings() string {
147147
return strings.Join(allStrings, "\n")
148148
}
149149

150-
func WorkspaceWithDeps(id string) *ObjWorkspace {
151-
workspace := Workspace(id)
150+
func WorkspaceWithDeps(id string, team *ObjTeam, template *ObjTemplate) *ObjWorkspace {
151+
// Building a workspace means the team needs access to the template + provisioner
152+
template.CanUseBy(team) // This should be a perm check
153+
154+
workspace := Workspace(id).Owner(team)
152155
build := Workspace_build(fmt.Sprintf("%s/build", id)).
153156
Workspace(workspace)
154157
agent := Workspace_agent(fmt.Sprintf("%s/agent", id)).
@@ -158,6 +161,9 @@ func WorkspaceWithDeps(id string) *ObjWorkspace {
158161
resources := Workspace_resources(fmt.Sprintf("%s/resources", id)).
159162
Workspace(workspace)
160163

164+
// Add the template + provisioner relations
165+
template.Workspace(workspace)
166+
161167
var _, _, _, _ = build, agent, app, resources
162168
return workspace
163169
}

0 commit comments

Comments
 (0)