From d143904aa9bbe54095395e6ba21ff30542b911fd Mon Sep 17 00:00:00 2001 From: Alex Crawford Date: Mon, 11 Aug 2014 17:57:10 -0700 Subject: [PATCH] configdrive: fix root path --- datasource/configdrive/configdrive.go | 2 +- datasource/configdrive/configdrive_test.go | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/datasource/configdrive/configdrive.go b/datasource/configdrive/configdrive.go index 870f3be..87f743c 100644 --- a/datasource/configdrive/configdrive.go +++ b/datasource/configdrive/configdrive.go @@ -17,7 +17,7 @@ type configDrive struct { } func NewDatasource(root string) *configDrive { - return &configDrive{path.Join(root, "openstack"), ioutil.ReadFile} + return &configDrive{root, ioutil.ReadFile} } func (cd *configDrive) IsAvailable() bool { diff --git a/datasource/configdrive/configdrive_test.go b/datasource/configdrive/configdrive_test.go index 26bc46b..afa0e40 100644 --- a/datasource/configdrive/configdrive_test.go +++ b/datasource/configdrive/configdrive_test.go @@ -112,3 +112,24 @@ func TestCDConfigRoot(t *testing.T) { } } } + +func TestNewDatasource(t *testing.T) { + for _, tt := range []struct { + root string + expectRoot string + }{ + { + root: "", + expectRoot: "", + }, + { + root: "/media/configdrive", + expectRoot: "/media/configdrive", + }, + } { + service := NewDatasource(tt.root) + if service.root != tt.expectRoot { + t.Fatalf("bad root (%q): want %q, got %q", tt.root, tt.expectRoot, service.root) + } + } +}