-
Notifications
You must be signed in to change notification settings - Fork 55
/
fields_spotinst_elastigroup_gcp_integrations.go
58 lines (48 loc) · 1.57 KB
/
fields_spotinst_elastigroup_gcp_integrations.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
53
54
55
56
57
58
package elastigroup_gcp_integrations
import (
"github.com/spotinst/spotinst-sdk-go/service/elastigroup/providers/gcp"
"github.com/spotinst/spotinst-sdk-go/spotinst"
"github.com/spotinst/terraform-provider-spotinst/spotinst/commons"
)
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// Setup
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
func Setup(fieldsMap map[commons.FieldName]*commons.GenericField) {
SetupDockerSwarm(fieldsMap)
SetupGKE(fieldsMap)
}
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// Utils
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
func expandGCPGroupAutoScaleHeadroom(data interface{}) (*gcp.AutoScaleHeadroom, error) {
if list := data.([]interface{}); len(list) > 0 {
headroom := &gcp.AutoScaleHeadroom{}
if list != nil && list[0] != nil {
m := list[0].(map[string]interface{})
if v, ok := m[string(CpuPerUnit)].(int); ok && v > 0 {
headroom.SetCPUPerUnit(spotinst.Int(v))
}
if v, ok := m[string(MemoryPerUnit)].(int); ok && v > 0 {
headroom.SetMemoryPerUnit(spotinst.Int(v))
}
if v, ok := m[string(NumOfUnits)].(int); ok && v > 0 {
headroom.SetNumOfUnits(spotinst.Int(v))
}
}
return headroom, nil
}
return nil, nil
}
func expandGCPGroupAutoScaleDown(data interface{}) (*gcp.AutoScaleDown, error) {
if list := data.([]interface{}); len(list) > 0 {
autoScaleDown := &gcp.AutoScaleDown{}
if list != nil && list[0] != nil {
m := list[0].(map[string]interface{})
if v, ok := m[string(EvaluationPeriods)].(int); ok && v > 0 {
autoScaleDown.SetEvaluationPeriods(spotinst.Int(v))
}
}
return autoScaleDown, nil
}
return nil, nil
}