kubelet/rkt: fix rkt version parsing.

Use SemVer to parse the version string.
pull/6/head
Yifan Gu 2015-08-21 10:45:11 -07:00
parent 65f4ebd927
commit a2b148b27b
1 changed files with 6 additions and 13 deletions

View File

@ -21,25 +21,18 @@ import (
"os/exec"
"strconv"
"strings"
appctypes "github.com/appc/spec/schema/types"
)
type rktVersion []int
func parseVersion(input string) (rktVersion, error) {
tail := strings.Index(input, "+")
if tail > 0 {
input = input[:tail]
nsv, err := appctypes.NewSemVer(input)
if err != nil {
return nil, err
}
var result rktVersion
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
return rktVersion{int(nsv.Major), int(nsv.Minor), int(nsv.Patch)}, nil
}
func (r rktVersion) Compare(other string) (int, error) {