Merge pull request #13042 from yifan-gu/rkt_fix_version

kubelet/rkt: fix rkt version parsing.
This commit is contained in:
Zach Loafman 2015-08-21 16:04:37 -07:00
commit f433efef8d

View File

@ -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) {