-
Notifications
You must be signed in to change notification settings - Fork 53
/
labels.go
49 lines (42 loc) · 1.01 KB
/
labels.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
package resources
import (
"github.com/rancher/opni/apis/v1beta1"
)
const (
PretrainedModelLabel = "opni.io/pretrained-model"
ServiceLabel = "opni.io/service"
OpniClusterName = "opni.io/cluster-name"
AppNameLabel = "app.kubernetes.io/name"
PartOfLabel = "app.kubernetes.io/part-of"
HostTopologyKey = "kubernetes.io/hostname"
)
func CombineLabels(maps ...map[string]string) map[string]string {
result := make(map[string]string)
for _, m := range maps {
for k, v := range m {
result[k] = v
}
}
return result
}
type ElasticLabels map[string]string
func NewElasticLabels() ElasticLabels {
return map[string]string{
"app": "opendistro-es",
}
}
func (l ElasticLabels) WithRole(role v1beta1.ElasticRole) ElasticLabels {
copied := map[string]string{}
for k, v := range l {
copied[k] = v
}
copied["role"] = string(role)
return copied
}
func (l ElasticLabels) Role() v1beta1.ElasticRole {
role, ok := l["role"]
if !ok {
return ""
}
return v1beta1.ElasticRole(role)
}