fix: backend name for Stateful services. (Service Fabric)
This commit is contained in:
parent
350d61b4a6
commit
799136a714
6 changed files with 174 additions and 151 deletions
62
vendor/github.com/containous/traefik-extra-service-fabric/labels.go
generated
vendored
62
vendor/github.com/containous/traefik-extra-service-fabric/labels.go
generated
vendored
|
@ -1,23 +1,59 @@
|
|||
package servicefabric
|
||||
|
||||
import "strings"
|
||||
import (
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func hasServiceLabel(service ServiceItemExtended, key string) bool {
|
||||
_, exists := service.Labels[key]
|
||||
return exists
|
||||
}
|
||||
|
||||
func getFuncBoolLabel(labelName string) func(service ServiceItemExtended) bool {
|
||||
func getFuncBoolLabel(labelName string, defaultValue bool) func(service ServiceItemExtended) bool {
|
||||
return func(service ServiceItemExtended) bool {
|
||||
return getBoolLabel(service, labelName)
|
||||
return getBoolValue(service.Labels, labelName, defaultValue)
|
||||
}
|
||||
}
|
||||
|
||||
func getBoolLabel(service ServiceItemExtended, labelName string) bool {
|
||||
value, exists := service.Labels[labelName]
|
||||
return exists && strings.EqualFold(strings.TrimSpace(value), "true")
|
||||
func getFuncServiceStringLabel(service ServiceItemExtended, labelName string, defaultValue string) string {
|
||||
return getStringValue(service.Labels, labelName, defaultValue)
|
||||
}
|
||||
|
||||
func getServiceLabelValue(service ServiceItemExtended, key string) string {
|
||||
return service.Labels[key]
|
||||
func hasFuncService(service ServiceItemExtended, labelName string) bool {
|
||||
return hasLabel(service.Labels, labelName)
|
||||
}
|
||||
|
||||
func getServiceLabelsWithPrefix(service ServiceItemExtended, prefix string) map[string]string {
|
||||
results := make(map[string]string)
|
||||
for k, v := range service.Labels {
|
||||
if strings.HasPrefix(k, prefix) {
|
||||
results[k] = v
|
||||
}
|
||||
}
|
||||
return results
|
||||
}
|
||||
|
||||
// must be replace by label.Has()
|
||||
// Deprecated
|
||||
func hasLabel(labels map[string]string, labelName string) bool {
|
||||
value, ok := labels[labelName]
|
||||
return ok && len(value) > 0
|
||||
}
|
||||
|
||||
// must be replace by label.GetStringValue()
|
||||
// Deprecated
|
||||
func getStringValue(labels map[string]string, labelName string, defaultValue string) string {
|
||||
if value, ok := labels[labelName]; ok && len(value) > 0 {
|
||||
return value
|
||||
}
|
||||
return defaultValue
|
||||
}
|
||||
|
||||
// must be replace by label.GetBoolValue()
|
||||
// Deprecated
|
||||
func getBoolValue(labels map[string]string, labelName string, defaultValue bool) bool {
|
||||
rawValue, ok := labels[labelName]
|
||||
if ok {
|
||||
v, err := strconv.ParseBool(rawValue)
|
||||
if err == nil {
|
||||
return v
|
||||
}
|
||||
}
|
||||
return defaultValue
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue