@@ -8,10 +8,21 @@ import (
8
8
"golang.org/x/xerrors"
9
9
)
10
10
11
+ type WorkspaceAgentScopeParams struct {
12
+ WorkspaceID uuid.UUID
13
+ OwnerID uuid.UUID
14
+ TemplateID uuid.UUID
15
+ VersionID uuid.UUID
16
+ }
17
+
11
18
// WorkspaceAgentScope returns a scope that is the same as ScopeAll but can only
12
19
// affect resources in the allow list. Only a scope is returned as the roles
13
20
// should come from the workspace owner.
14
- func WorkspaceAgentScope (workspaceID ,ownerID uuid.UUID )Scope {
21
+ func WorkspaceAgentScope (params WorkspaceAgentScopeParams )Scope {
22
+ if params .WorkspaceID == uuid .Nil || params .OwnerID == uuid .Nil || params .TemplateID == uuid .Nil || params .VersionID == uuid .Nil {
23
+ panic ("all uuids must be non-nil, this is a developer error" )
24
+ }
25
+
15
26
allScope ,err := ScopeAll .Expand ()
16
27
if err != nil {
17
28
panic ("failed to expand scope all, this should never happen" )
@@ -23,10 +34,13 @@ func WorkspaceAgentScope(workspaceID, ownerID uuid.UUID) Scope {
23
34
// and evolving.
24
35
Role :allScope .Role ,
25
36
// This prevents the agent from being able to access any other resource.
37
+ // Include the list of IDs of anything that is required for the
38
+ // agent to function.
26
39
AllowIDList : []string {
27
- workspaceID .String (),
28
- ownerID .String (),
29
- // TODO: Might want to include the template the workspace uses too?
40
+ params .WorkspaceID .String (),
41
+ params .TemplateID .String (),
42
+ params .VersionID .String (),
43
+ params .OwnerID .String (),
30
44
},
31
45
}
32
46
}