Fix Labels/annotation logs and values.

This commit is contained in:
Ludovic Fernandez 2017-11-30 09:26:03 +01:00 committed by Traefiker
parent 077b39d7c6
commit f084d2a28b
6 changed files with 27 additions and 37 deletions

View file

@ -75,3 +75,19 @@ func ServiceLabel(key, serviceName string) string {
}
return key
}
// SplitAndTrimString splits separatedString at the comma character and trims each
// piece, filtering out empty pieces. Returns the list of pieces or nil if the input
// did not contain a non-empty piece.
func SplitAndTrimString(base string) []string {
var trimmedStrings []string
for _, s := range strings.Split(base, ",") {
s = strings.TrimSpace(s)
if len(s) > 0 {
trimmedStrings = append(trimmedStrings, s)
}
}
return trimmedStrings
}