diff --git a/datasource/configdrive/configdrive.go b/datasource/configdrive/configdrive.go index 6947a7f..a661746 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 b283f92..c050324 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) + } + } +}