forked from taskcluster/generic-worker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
os_groups.go
52 lines (42 loc) · 1.22 KB
/
os_groups.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package main
import (
"github.com/taskcluster/taskcluster-base-go/scopes"
)
// one instance overall - represents feature
type OSGroupsFeature struct {
}
// one instance per task
type OSGroups struct {
Task *TaskRun
// keep track of which groups we successfully update
AddedGroups []string
}
func (feature *OSGroupsFeature) Name() string {
return "OS Groups"
}
func (feature *OSGroupsFeature) Initialise() error {
return nil
}
func (feature *OSGroupsFeature) PersistState() error {
return nil
}
func (feature *OSGroupsFeature) IsEnabled(task *TaskRun) bool {
// always enabled, since scopes protect usage at a group level
return true
}
func (feature *OSGroupsFeature) NewTaskFeature(task *TaskRun) TaskFeature {
osGroups := &OSGroups{
Task: task,
}
return osGroups
}
func (osGroups *OSGroups) ReservedArtifacts() []string {
return []string{}
}
func (osGroups *OSGroups) RequiredScopes() scopes.Required {
requiredScopes := make([]string, len(osGroups.Task.Payload.OSGroups), len(osGroups.Task.Payload.OSGroups))
for i, osGroup := range osGroups.Task.Payload.OSGroups {
requiredScopes[i] = "generic-worker:os-group:" + config.ProvisionerID + "/" + config.WorkerType + "/" + osGroup
}
return scopes.Required{requiredScopes}
}