mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 20:24:09 +00:00
Merge pull request #13042 from yifan-gu/rkt_fix_version
kubelet/rkt: fix rkt version parsing.
This commit is contained in:
commit
f433efef8d
@ -21,25 +21,18 @@ import (
|
|||||||
"os/exec"
|
"os/exec"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
appctypes "github.com/appc/spec/schema/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
type rktVersion []int
|
type rktVersion []int
|
||||||
|
|
||||||
func parseVersion(input string) (rktVersion, error) {
|
func parseVersion(input string) (rktVersion, error) {
|
||||||
tail := strings.Index(input, "+")
|
nsv, err := appctypes.NewSemVer(input)
|
||||||
if tail > 0 {
|
if err != nil {
|
||||||
input = input[:tail]
|
return nil, err
|
||||||
}
|
}
|
||||||
var result rktVersion
|
return rktVersion{int(nsv.Major), int(nsv.Minor), int(nsv.Patch)}, nil
|
||||||
tuples := strings.Split(input, ".")
|
|
||||||
for _, t := range tuples {
|
|
||||||
n, err := strconv.Atoi(t)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
result = append(result, n)
|
|
||||||
}
|
|
||||||
return result, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r rktVersion) Compare(other string) (int, error) {
|
func (r rktVersion) Compare(other string) (int, error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user