-
Notifications
You must be signed in to change notification settings - Fork 6
/
common.go
52 lines (41 loc) · 1.1 KB
/
common.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 key
import (
"strconv"
"github.com/giantswarm/k8smetadata/pkg/annotation"
"github.com/giantswarm/k8smetadata/pkg/label"
)
func ReleaseVersion(getter LabelsGetter) string {
return getter.GetLabels()[label.ReleaseVersion]
}
func ClusterID(getter LabelsGetter) string {
return getter.GetLabels()[label.Cluster]
}
func MachineDeploymentName(getter AnnotationsGetter) string {
annotations := getter.GetAnnotations()
if annotations == nil {
return ""
}
return annotations[annotation.MachineDeploymentName]
}
func MachinePoolName(getter AnnotationsGetter) string {
annotations := getter.GetAnnotations()
if annotations == nil {
return ""
}
return annotations[annotation.MachinePoolName]
}
func MachinePoolScaling(getter AnnotationsGetter) (int, int) {
annotations := getter.GetAnnotations()
if annotations != nil {
minReplicas, err := strconv.Atoi(annotations[annotation.NodePoolMinSize])
if err != nil {
return -1, -1
}
maxReplicas, err := strconv.Atoi(annotations[annotation.NodePoolMaxSize])
if err != nil {
return -1, -1
}
return minReplicas, maxReplicas
}
return -1, -1
}