mirror of
https://github.com/kemko/nomad.git
synced 2026-01-08 19:35:41 +03:00
Merge pull request #314 from achanda/rkt-version
Just put the version as string
This commit is contained in:
@@ -21,8 +21,8 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
reRktVersion = regexp.MustCompile("rkt version ([\\d\\.]+).+")
|
||||
reAppcVersion = regexp.MustCompile("appc version ([\\d\\.]+).+")
|
||||
reRktVersion = regexp.MustCompile(`rkt version (\d[.\d]+)`)
|
||||
reAppcVersion = regexp.MustCompile(`appc version (\d[.\d]+)`)
|
||||
)
|
||||
|
||||
// RktDriver is a driver for running images via Rkt
|
||||
@@ -67,13 +67,13 @@ func (d *RktDriver) Fingerprint(cfg *config.Config, node *structs.Node) (bool, e
|
||||
out := strings.TrimSpace(string(outBytes))
|
||||
|
||||
rktMatches := reRktVersion.FindStringSubmatch(out)
|
||||
appcMatches := reRktVersion.FindStringSubmatch(out)
|
||||
appcMatches := reAppcVersion.FindStringSubmatch(out)
|
||||
if len(rktMatches) != 2 || len(appcMatches) != 2 {
|
||||
return false, fmt.Errorf("Unable to parse Rkt version string: %#v", rktMatches)
|
||||
}
|
||||
|
||||
node.Attributes["driver.rkt"] = "1"
|
||||
node.Attributes["driver.rkt.version"] = rktMatches[0]
|
||||
node.Attributes["driver.rkt.version"] = rktMatches[1]
|
||||
node.Attributes["driver.rkt.appc.version"] = appcMatches[1]
|
||||
|
||||
return true, nil
|
||||
|
||||
@@ -15,6 +15,21 @@ import (
|
||||
ctestutils "github.com/hashicorp/nomad/client/testutil"
|
||||
)
|
||||
|
||||
func TestRktVersionRegex(t *testing.T) {
|
||||
input_rkt := "rkt version 0.8.1"
|
||||
input_appc := "appc version 1.2.0"
|
||||
expected_rkt := "0.8.1"
|
||||
expected_appc := "1.2.0"
|
||||
rktMatches := reRktVersion.FindStringSubmatch(input_rkt)
|
||||
appcMatches := reAppcVersion.FindStringSubmatch(input_appc)
|
||||
if rktMatches[1] != expected_rkt {
|
||||
fmt.Printf("Test failed; got %q; want %q\n", rktMatches[1], expected_rkt)
|
||||
}
|
||||
if appcMatches[1] != expected_appc {
|
||||
fmt.Printf("Test failed; got %q; want %q\n", appcMatches[1], expected_appc)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRktDriver_Handle(t *testing.T) {
|
||||
h := &rktHandle{
|
||||
proc: &os.Process{Pid: 123},
|
||||
|
||||
Reference in New Issue
Block a user