-
Notifications
You must be signed in to change notification settings - Fork 386
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add data sources for retrieving UC tables
* Added `databricks_catalogs` data * Added `databricks_schemas` data * Added `databricks_tables` data Fixes #1105
- Loading branch information
Showing
10 changed files
with
123 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#FileLock | ||
#Fri Mar 04 20:10:36 CET 2022 | ||
hostName=localhost | ||
id=17f563717e2108ab2ed927d0890b5d32b035b00a997 | ||
method=file | ||
server=localhost\:58947 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package catalog | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/databrickslabs/terraform-provider-databricks/common" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
) | ||
|
||
func DataSourceCatalogs() *schema.Resource { | ||
var data struct { | ||
Ids []string `json:"ids,omitempty" tf:"computed,slice_set"` | ||
} | ||
return common.DataResource(&data, func(ctx context.Context, c *common.DatabricksClient) error { | ||
catalogsAPI := NewCatalogsAPI(ctx, c) | ||
catalogs, err := catalogsAPI.list() | ||
if err != nil { | ||
return err | ||
} | ||
for _, v := range catalogs.Catalogs { | ||
data.Ids = append(data.Ids, v.Name) | ||
} | ||
return nil | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package catalog | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/databrickslabs/terraform-provider-databricks/common" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
) | ||
|
||
func DataSourceSchemas() *schema.Resource { | ||
var data struct { | ||
CatalogName string `json:"catalog_name"` | ||
Ids []string `json:"ids,omitempty" tf:"computed,slice_set"` | ||
} | ||
return common.DataResource(&data, func(ctx context.Context, c *common.DatabricksClient) error { | ||
schemasAPI := NewSchemasAPI(ctx, c) | ||
schemas, err := schemasAPI.listByCatalog(data.CatalogName) | ||
if err != nil { | ||
return err | ||
} | ||
for _, v := range schemas.Schemas { | ||
data.Ids = append(data.Ids, v.FullName) | ||
} | ||
return nil | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package catalog | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/databrickslabs/terraform-provider-databricks/common" | ||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" | ||
) | ||
|
||
func DataSourceTables() *schema.Resource { | ||
var data struct { | ||
CatalogName string `json:"catalog_name"` | ||
SchemaName string `json:"schema_name"` | ||
Ids []string `json:"ids,omitempty" tf:"computed,slice_set"` | ||
} | ||
return common.DataResource(&data, func(ctx context.Context, c *common.DatabricksClient) error { | ||
tablesAPI := NewTablesAPI(ctx, c) | ||
tables, err := tablesAPI.listTables(data.CatalogName, data.SchemaName) | ||
if err != nil { | ||
return err | ||
} | ||
for _, v := range tables.Tables { | ||
data.Ids = append(data.Ids, v.FullName()) | ||
} | ||
return nil | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters