diff --git a/scheduler/feasible.go b/scheduler/feasible.go index 289fbe03c23..c345cb94dfb 100644 --- a/scheduler/feasible.go +++ b/scheduler/feasible.go @@ -606,7 +606,7 @@ func checkLexicalOrder(op string, lVal, rVal interface{}) bool { // checkVersionMatch is used to compare a version on the // left hand side with a set of constraints on the right hand side -func checkVersionMatch(ctx Context, parse VerConstraintParser, lVal, rVal interface{}) bool { +func checkVersionMatch(ctx Context, parse verConstraintParser, lVal, rVal interface{}) bool { // Parse the version var versionStr string switch v := lVal.(type) { @@ -642,7 +642,7 @@ func checkVersionMatch(ctx Context, parse VerConstraintParser, lVal, rVal interf // checkAttributeVersionMatch is used to compare a version on the // left hand side with a set of constraints on the right hand side -func checkAttributeVersionMatch(ctx Context, parse VerConstraintParser, lVal, rVal *psstructs.Attribute) bool { +func checkAttributeVersionMatch(ctx Context, parse verConstraintParser, lVal, rVal *psstructs.Attribute) bool { // Parse the version var versionStr string if s, ok := lVal.GetString(); ok { @@ -1166,14 +1166,18 @@ func checkAttributeConstraint(ctx Context, operand string, lVal, rVal *psstructs } +// VerConstraints is the interface implemented by both go-verson constraints +// and semver constraints. type VerConstraints interface { Check(v *version.Version) bool String() string } -type VerConstraintParser func(verConstraint string) VerConstraints +// verConstraintParser returns a version constraints implementation (go-version +// or semver). +type verConstraintParser func(verConstraint string) VerConstraints -func newVersionConstraintParser(ctx Context) VerConstraintParser { +func newVersionConstraintParser(ctx Context) verConstraintParser { cache := ctx.VersionConstraintCache() return func(cstr string) VerConstraints { @@ -1191,7 +1195,7 @@ func newVersionConstraintParser(ctx Context) VerConstraintParser { } } -func newSemverConstraintParser(ctx Context) VerConstraintParser { +func newSemverConstraintParser(ctx Context) verConstraintParser { cache := ctx.SemverConstraintCache() return func(cstr string) VerConstraints {