rebase: update k8s.io packages to v0.29.0

Signed-off-by: Niels de Vos <ndevos@ibm.com>
This commit is contained in:
Niels de Vos
2023-12-20 13:23:59 +01:00
committed by mergify[bot]
parent 328a264202
commit f080b9e0c9
367 changed files with 21340 additions and 11878 deletions

View File

@ -18,6 +18,7 @@ package version
import (
"bytes"
"errors"
"fmt"
"regexp"
"strconv"
@ -85,6 +86,47 @@ func parse(str string, semver bool) (*Version, error) {
return v, nil
}
// HighestSupportedVersion returns the highest supported version
// This function assumes that the highest supported version must be v1.x.
func HighestSupportedVersion(versions []string) (*Version, error) {
if len(versions) == 0 {
return nil, errors.New("empty array for supported versions")
}
var (
highestSupportedVersion *Version
theErr error
)
for i := len(versions) - 1; i >= 0; i-- {
currentHighestVer, err := ParseGeneric(versions[i])
if err != nil {
theErr = err
continue
}
if currentHighestVer.Major() > 1 {
continue
}
if highestSupportedVersion == nil || highestSupportedVersion.LessThan(currentHighestVer) {
highestSupportedVersion = currentHighestVer
}
}
if highestSupportedVersion == nil {
return nil, fmt.Errorf(
"could not find a highest supported version from versions (%v) reported: %+v",
versions, theErr)
}
if highestSupportedVersion.Major() != 1 {
return nil, fmt.Errorf("highest supported version reported is %v, must be v1.x", highestSupportedVersion)
}
return highestSupportedVersion, nil
}
// ParseGeneric parses a "generic" version string. The version string must consist of two
// or more dot-separated numeric fields (the first of which can't have leading zeroes),
// followed by arbitrary uninterpreted data (which need not be separated from the final