Commit a2b148b2 authored by Yifan Gu's avatar Yifan Gu

kubelet/rkt: fix rkt version parsing.

Use SemVer to parse the version string.
parent 65f4ebd9
...@@ -21,25 +21,18 @@ import ( ...@@ -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
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) { func (r rktVersion) Compare(other string) (int, error) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment