homogenization of templates: Marathon

This commit is contained in:
Ludovic Fernandez 2018-01-10 11:58:03 +01:00 committed by Traefiker
parent b60edd9ee9
commit 870c0b5cf4
6 changed files with 1646 additions and 825 deletions

View file

@ -93,6 +93,14 @@ func GetBoolValue(labels map[string]string, labelName string, defaultValue bool)
return defaultValue
}
// GetBoolValueP get bool value associated to a label
func GetBoolValueP(labels *map[string]string, labelName string, defaultValue bool) bool {
if labels == nil {
return defaultValue
}
return GetBoolValue(*labels, labelName, defaultValue)
}
// GetIntValue get int value associated to a label
func GetIntValue(labels map[string]string, labelName string, defaultValue int) int {
if rawValue, ok := labels[labelName]; ok {
@ -229,6 +237,14 @@ func HasPrefix(labels map[string]string, prefix string) bool {
return false
}
// HasPrefixP Check if a value is associated to a less one label with a prefix
func HasPrefixP(labels *map[string]string, prefix string) bool {
if labels == nil {
return false
}
return HasPrefix(*labels, prefix)
}
// FindServiceSubmatch split service label
func FindServiceSubmatch(name string) []string {
matches := ServicesPropertiesRegexp.FindStringSubmatch(name)