github.com/caos/orbos@v1.5.14-0.20221103111702-e6cd0cea7ad4/internal/operator/boom/labels/labels.go (about) 1 package labels 2 3 import "github.com/caos/orbos/internal/operator/boom/name" 4 5 var ( 6 instanceName = "boom" 7 ) 8 9 func GetGlobalLabels() Labels { 10 return map[string]string{ 11 "app.kubernetes.io/managed-by": "boom.caos.ch", 12 "boom.caos.ch/part-of": "boom", 13 "boom.caos.ch/instance": instanceName, 14 } 15 } 16 17 func GetAllApplicationLabels(appName name.Application) Labels { 18 return GetGlobalLabels(). 19 Append(GetApplicationLabels(appName)) 20 } 21 22 func GetApplicationLabels(appName name.Application) Labels { 23 return map[string]string{ 24 "boom.caos.ch/application": appName.String(), 25 } 26 } 27 28 func GetPromSelector(instanceName string) Labels { 29 return map[string]string{ 30 "boom.caos.ch/prometheus": instanceName, 31 } 32 } 33 34 func GetMonitorLabels(instanceName string, appName name.Application) map[string]string { 35 return GetApplicationLabels(appName). 36 Append(GetPromSelector(instanceName)) 37 } 38 39 type Labels map[string]string 40 41 func (l Labels) Append(labels map[string]string) Labels { 42 for k, v := range labels { 43 l[k] = v 44 } 45 return l 46 } 47 48 func GetMonitorSelectorLabels(instanceName string) map[string]string { 49 labels := make(map[string]string, 0) 50 labels["boom.caos.ch/prometheus"] = instanceName 51 return labels 52 } 53 54 func GetRuleLabels(instanceName string, appName name.Application) map[string]string { 55 labels := GetApplicationLabels(appName) 56 addLabels := GetRuleSelectorLabels(instanceName) 57 58 for k, v := range addLabels { 59 labels[k] = v 60 } 61 return labels 62 } 63 64 func GetRuleSelectorLabels(instanceName string) map[string]string { 65 labels := make(map[string]string, 0) 66 labels["boom.caos.ch/prometheus"] = instanceName 67 return labels 68 }