-
Notifications
You must be signed in to change notification settings - Fork 86
/
start_attributes.go
45 lines (36 loc) · 1.07 KB
/
start_attributes.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
package backend
import "time"
// StartAttributes contains some parts of the config which can be used to
// determine the type of instance to boot up (for example, what image to use)
type StartAttributes struct {
Language string `json:"language"`
OsxImage string `json:"osx_image"`
Dist string `json:"dist"`
Group string `json:"group"`
OS string `json:"os"`
ImageName string `json:"image_name"`
// The VMType isn't stored in the config directly, but in the top level of
// the job payload, see the worker.JobPayload struct.
VMType string `json:"-"`
// HardTimeout isn't stored in the config directly, but is injected
// from the processor
HardTimeout time.Duration `json:"-"`
}
// SetDefaults sets any missing required attributes to the default values provided
func (sa *StartAttributes) SetDefaults(lang, dist, group, os, vmType string) {
if sa.Language == "" {
sa.Language = lang
}
if sa.Dist == "" {
sa.Dist = dist
}
if sa.Group == "" {
sa.Group = group
}
if sa.OS == "" {
sa.OS = os
}
if sa.VMType == "" {
sa.VMType = vmType
}
}