Skip to content

Commit 9a08630

Browse files
authored
Add workspace_path to the databricks_directory data source (#3051)
This is for parity with resources
1 parent b6b9b93 commit 9a08630

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

docs/data-sources/directory.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@ data "databricks_directory" "prod" {
2424
This data source exports the following attributes:
2525

2626
* `object_id` - directory object ID
27+
* `workspace_path` - path on Workspace File System (WSFS) in form of `/Workspace` + `path`

docs/resources/directory.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ In addition to all arguments above, the following attributes are exported:
2929

3030
- `id` - Path of directory on workspace
3131
- `object_id` - Unique identifier for a DIRECTORY
32+
- `workspace_path` - path on Workspace File System (WSFS) in form of `/Workspace` + `path`
3233

3334
## Access Control
3435

workspace/data_directory.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ func DataSourceDirectory() *schema.Resource {
2020
Optional: true,
2121
Computed: true,
2222
},
23+
"workspace_path": {
24+
Type: schema.TypeString,
25+
Computed: true,
26+
},
2327
}
2428
return &schema.Resource{
2529
Schema: s,
@@ -36,6 +40,7 @@ func DataSourceDirectory() *schema.Resource {
3640
d.SetId(data.Path)
3741
d.Set("object_id", data.ObjectID)
3842
d.Set("path", path)
43+
d.Set("workspace_path", "/Workspace"+data.Path)
3944
return nil
4045
},
4146
}

workspace/data_directory_test.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@ import (
44
"testing"
55

66
"github.com/databricks/terraform-provider-databricks/qa"
7-
"github.com/stretchr/testify/assert"
8-
"github.com/stretchr/testify/require"
97
)
108

119
func TestDataSourceDirectory(t *testing.T) {
12-
d, err := qa.ResourceFixture{
10+
qa.ResourceFixture{
1311
Fixtures: []qa.HTTPFixture{
1412
{
1513
Method: "GET",
@@ -28,10 +26,11 @@ func TestDataSourceDirectory(t *testing.T) {
2826
State: map[string]any{
2927
"path": "/a/b/c",
3028
},
31-
}.Apply(t)
32-
require.NoError(t, err)
33-
assert.Equal(t, "/a/b/c", d.Id())
34-
assert.Equal(t, 987, d.Get("object_id").(int))
29+
}.ApplyAndExpectData(t, map[string]any{
30+
"id": "/a/b/c",
31+
"object_id": 987,
32+
"workspace_path": "/Workspace/a/b/c",
33+
})
3534
}
3635

3736
func TestDataSourceDirectory_NotDirectory(t *testing.T) {

0 commit comments

Comments
 (0)