1
0
Fork 0

Remove Marathon provider

This commit is contained in:
Romain 2022-12-19 11:52:05 +01:00 committed by GitHub
parent 2ad1fd725a
commit 2b67f1f66f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
80 changed files with 11 additions and 7802 deletions

View file

@ -3,22 +3,16 @@ package constraints
import (
"errors"
"regexp"
"strings"
"github.com/vulcand/predicate"
)
// MarathonConstraintPrefix is the prefix for each label's key created from a Marathon application constraint.
// It is used in order to create a specific and unique pattern for these labels.
const MarathonConstraintPrefix = "Traefik-Marathon-505F9E15-BDC7-45E7-828D-C06C7BAB8091"
type constraintLabelFunc func(map[string]string) bool
// MatchLabels reports whether the expression matches with the given labels.
// The expression must match any logical boolean combination of:
// - `Label(labelName, labelValue)`
// - `LabelRegex(labelName, regexValue)`
// - `MarathonConstraint(field:operator:value)`.
// - `LabelRegex(labelName, regexValue)`.
func MatchLabels(labels map[string]string, expr string) (bool, error) {
if expr == "" {
return true, nil
@ -31,9 +25,8 @@ func MatchLabels(labels map[string]string, expr string) (bool, error) {
OR: orLabelFunc,
},
Functions: map[string]interface{}{
"Label": labelFn,
"LabelRegex": labelRegexFn,
"MarathonConstraint": marathonFn,
"Label": labelFn,
"LabelRegex": labelRegexFn,
},
})
if err != nil {
@ -68,19 +61,6 @@ func labelRegexFn(name, expr string) constraintLabelFunc {
}
}
func marathonFn(value string) constraintLabelFunc {
return func(labels map[string]string) bool {
for k, v := range labels {
if strings.HasPrefix(k, MarathonConstraintPrefix) {
if v == value {
return true
}
}
}
return false
}
}
func andLabelFunc(a, b constraintLabelFunc) constraintLabelFunc {
return func(labels map[string]string) bool {
return a(labels) && b(labels)