Skip to content

Commit

Permalink
Migrate databricks_shares data source to sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
nkvuong committed Mar 6, 2023
1 parent 29cea04 commit 506a8bb
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions catalog/data_shares.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,21 @@ package catalog
import (
"context"

"github.com/databricks/databricks-sdk-go"
"github.com/databricks/terraform-provider-databricks/common"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

func DataSourceShares() *schema.Resource {
type sharesData struct {
return common.WorkspaceData(func(ctx context.Context, data *struct {
Shares []string `json:"shares,omitempty" tf:"computed,slice_set"`
}
return common.DataResource(sharesData{}, func(ctx context.Context, e any, c *common.DatabricksClient) error {
data := e.(*sharesData)
sharesAPI := NewSharesAPI(ctx, c)
shares, err := sharesAPI.list()
}, w *databricks.WorkspaceClient) error {

shares, err := w.Shares.ListAll(ctx)
if err != nil {
return err
}
for _, share := range shares.Shares {
for _, share := range shares {
data.Shares = append(data.Shares, share.Name)
}
return nil
Expand Down

0 comments on commit 506a8bb

Please sign in to comment.