Add ValidateSelector to versioner interface and consume it

We can refactor furthermore by dropping the package methods, as now we
can consume a versioner in all places that requires it
This commit is contained in:
Ettore Di Giacinto
2020-04-05 15:09:51 +02:00
parent 5a5e7f1dfa
commit 77ba4193aa
5 changed files with 34 additions and 28 deletions

View File

@@ -43,6 +43,23 @@ func (w *WrappedVersioner) Validate(version string) error {
return nil
}
func (w *WrappedVersioner) ValidateSelector(version string, selector string) bool {
vS, err := ParseVersion(selector)
if err != nil {
return false
}
vSI, err := ParseVersion(version)
if err != nil {
return false
}
ok, err := PackageAdmit(vS, vSI)
if err != nil {
return false
}
return ok
}
func (w *WrappedVersioner) Sanitize(s string) string {
return strings.ReplaceAll(s, "_", "-")
}