-
Notifications
You must be signed in to change notification settings - Fork 53
/
labels.go
59 lines (51 loc) · 1.34 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
50
51
52
53
54
55
56
57
58
59
package resources
import (
"github.com/rancher/opni/apis/v1beta2"
)
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"
InstanceLabel = "app.kubernetes.io/instance"
HostTopologyKey = "kubernetes.io/hostname"
OpniClusterID = "opni.io/cluster-id"
OpniBootstrapToken = "opni.io/bootstrap-token"
OpniInferenceType = "opni.io/inference-type"
)
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 OpensearchLabels map[string]string
func NewOpensearchLabels() OpensearchLabels {
return map[string]string{
"app": "opensearch",
}
}
func NewGatewayLabels() map[string]string {
return map[string]string{
"app.kubernetes.io/name": "opni-gateway",
}
}
func (l OpensearchLabels) WithRole(role v1beta2.OpensearchRole) OpensearchLabels {
copied := map[string]string{}
for k, v := range l {
copied[k] = v
}
copied["role"] = string(role)
return copied
}
func (l OpensearchLabels) Role() v1beta2.OpensearchRole {
role, ok := l["role"]
if !ok {
return ""
}
return v1beta2.OpensearchRole(role)
}