diff options
author | Flavio Castelli <fcastelli@suse.com> | 2018-02-20 19:37:44 +0100 |
---|---|---|
committer | Flavio Castelli <fcastelli@suse.com> | 2018-02-20 19:37:44 +0100 |
commit | f2cef405133f73155f4085f50f6b5dd6ce38d11a (patch) | |
tree | d0bad561c27b5a48a5b5fe3867652c70055e3135 | |
parent | 09834dbcf6d3353850cea0f51b4b07d811d3628d (diff) | |
parent | 79e8a4ee25dfec9ecbeb0b65f0caed38e15da67c (diff) | |
download | terraform-provider-libvirt-f2cef405133f73155f4085f50f6b5dd6ce38d11a.tar terraform-provider-libvirt-f2cef405133f73155f4085f50f6b5dd6ce38d11a.tar.gz |
Merge branch 'keyless-kernel-cmdlines'
-rw-r--r-- | libvirt/utils_domain_def.go | 5 | ||||
-rw-r--r-- | libvirt/utils_domain_def_test.go | 21 |
2 files changed, 9 insertions, 17 deletions
diff --git a/libvirt/utils_domain_def.go b/libvirt/utils_domain_def.go index 90175de1..95c6c0d6 100644 --- a/libvirt/utils_domain_def.go +++ b/libvirt/utils_domain_def.go @@ -70,10 +70,7 @@ func splitKernelCmdLine(cmdLine string) ([]map[string]string, error) { continue } - kv := strings.Split(argVal, "=") - if len(kv) != 2 { - return nil, fmt.Errorf("Can't parse kernel command line: '%s'", cmdLine) - } + kv := strings.SplitN(argVal, "=", 2) k, v := kv[0], kv[1] // if the key is duplicate, start a new map if _, ok := currCmdLine[k]; ok { diff --git a/libvirt/utils_domain_def_test.go b/libvirt/utils_domain_def_test.go index 746c095b..3b3061c5 100644 --- a/libvirt/utils_domain_def_test.go +++ b/libvirt/utils_domain_def_test.go @@ -12,8 +12,14 @@ func init() { } func TestSplitKernelCmdLine(t *testing.T) { - e := []map[string]string{{"foo": "bar"}, {"foo": "bar", "key": "val"}, {"_": "nosplash rw"}} - r, err := splitKernelCmdLine("foo=bar foo=bar key=val nosplash rw") + e := []map[string]string{ + {"foo": "bar"}, + { + "foo": "bar", + "key": "val", + "root": "UUID=aa52d618-a2c4-4aad-aeb7-68d9e3a2c91d"}, + {"_": "nosplash rw"}} + r, err := splitKernelCmdLine("foo=bar foo=bar key=val root=UUID=aa52d618-a2c4-4aad-aeb7-68d9e3a2c91d nosplash rw") if !reflect.DeepEqual(r, e) { t.Fatalf("got='%s' expected='%s'", spew.Sdump(r), spew.Sdump(e)) } @@ -22,17 +28,6 @@ func TestSplitKernelCmdLine(t *testing.T) { } } -func TestSplitKernelInvalidCmdLine(t *testing.T) { - v := "foo=barfoo=bar" - r, err := splitKernelCmdLine(v) - if r != nil { - t.Fatalf("got='%s' expected='%s'", spew.Sdump(r), err) - } - if err == nil { - t.Errorf("Expected error for parsing '%s'", v) - } -} - func TestSplitKernelEmptyCmdLine(t *testing.T) { var e []map[string]string r, err := splitKernelCmdLine("") |