/
machinepool.go
50 lines (42 loc) · 1.25 KB
/
machinepool.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
package aws
// MachinePool stores the configuration for a machine pool installed
// on AWS.
type MachinePool struct {
// Zones is list of availability zones that can be used.
Zones []string `json:"zones,omitempty"`
// InstanceType defines the ec2 instance type.
// eg. m4-large
InstanceType string `json:"type"`
// EC2RootVolume defines the storage for ec2 instance.
EC2RootVolume `json:"rootVolume"`
}
// Set sets the values from `required` to `a`.
func (a *MachinePool) Set(required *MachinePool) {
if required == nil || a == nil {
return
}
if len(required.Zones) > 0 {
a.Zones = required.Zones
}
if required.InstanceType != "" {
a.InstanceType = required.InstanceType
}
if required.EC2RootVolume.IOPS != 0 {
a.EC2RootVolume.IOPS = required.EC2RootVolume.IOPS
}
if required.EC2RootVolume.Size != 0 {
a.EC2RootVolume.Size = required.EC2RootVolume.Size
}
if required.EC2RootVolume.Type != "" {
a.EC2RootVolume.Type = required.EC2RootVolume.Type
}
}
// EC2RootVolume defines the storage for an ec2 instance.
type EC2RootVolume struct {
// IOPS defines the iops for the storage.
IOPS int `json:"iops"`
// Size defines the size of the storage.
Size int `json:"size"`
// Type defines the type of the storage.
Type string `json:"type"`
}