mirror of
https://github.com/ceph/ceph-csi.git
synced 2025-06-13 18:43:34 +00:00
rebase: update k8s.io packages to v0.29.0
Signed-off-by: Niels de Vos <ndevos@ibm.com>
This commit is contained in:
committed by
mergify[bot]
parent
328a264202
commit
f080b9e0c9
42
vendor/k8s.io/apimachinery/pkg/util/version/version.go
generated
vendored
42
vendor/k8s.io/apimachinery/pkg/util/version/version.go
generated
vendored
@ -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
|
||||
|
Reference in New Issue
Block a user