Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions access/resource_ip_access_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type ipAccessListUpdateRequest struct {
ListType settings.ListType `json:"list_type"`
IpAddresses []string `json:"ip_addresses"`
Enabled bool `json:"enabled,omitempty" tf:"default:true"`
common.Namespace
}

// ResourceIPAccessList manages IP access lists
Expand All @@ -26,12 +27,13 @@ func ResourceIPAccessList() common.Resource {
Type: schema.TypeString,
ValidateFunc: validation.Any(validation.IsIPv4Address, validation.IsCIDR),
}
common.NamespaceCustomizeSchemaMap(s)
return s
})
return common.Resource{
Schema: s,
Create: func(ctx context.Context, d *schema.ResourceData, c *common.DatabricksClient) error {
w, err := c.WorkspaceClient()
w, err := c.WorkspaceClientUnifiedProvider(ctx, d)
if err != nil {
return err
}
Expand All @@ -45,7 +47,7 @@ func ResourceIPAccessList() common.Resource {
return nil
},
Read: func(ctx context.Context, d *schema.ResourceData, c *common.DatabricksClient) error {
w, err := c.WorkspaceClient()
w, err := c.WorkspaceClientUnifiedProvider(ctx, d)
if err != nil {
return err
}
Expand All @@ -57,7 +59,7 @@ func ResourceIPAccessList() common.Resource {
return nil
},
Update: func(ctx context.Context, d *schema.ResourceData, c *common.DatabricksClient) error {
w, err := c.WorkspaceClient()
w, err := c.WorkspaceClientUnifiedProvider(ctx, d)
if err != nil {
return err
}
Expand All @@ -67,11 +69,14 @@ func ResourceIPAccessList() common.Resource {
return w.IpAccessLists.Update(ctx, iacl)
},
Delete: func(ctx context.Context, d *schema.ResourceData, c *common.DatabricksClient) error {
w, err := c.WorkspaceClient()
w, err := c.WorkspaceClientUnifiedProvider(ctx, d)
if err != nil {
return err
}
return w.IpAccessLists.DeleteByIpAccessListId(ctx, d.Id())
},
CustomizeDiff: func(ctx context.Context, d *schema.ResourceDiff) error {
return common.NamespaceCustomizeDiff(d)
},
}
}
15 changes: 11 additions & 4 deletions catalog/resource_artifact_allowlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,18 @@ type ArtifactAllowlistInfo struct {
CreatedBy string `json:"created_by,omitempty" tf:"computed"`
// Unique identifier of parent metastore.
MetastoreId string `json:"metastore_id,omitempty" tf:"computed"`
common.Namespace
}

func ResourceArtifactAllowlist() common.Resource {
allowlistSchema := common.StructToSchema(ArtifactAllowlistInfo{}, common.NoCustomize)
allowlistSchema := common.StructToSchema(ArtifactAllowlistInfo{}, func(s map[string]*schema.Schema) map[string]*schema.Schema {
common.NamespaceCustomizeSchemaMap(s)
return s
})
p := common.NewPairID("metastore_id", "artifact_type")

createOrUpdate := func(ctx context.Context, d *schema.ResourceData, c *common.DatabricksClient) error {
w, err := c.WorkspaceClient()
w, err := c.WorkspaceClientUnifiedProvider(ctx, d)
if err != nil {
return err
}
Expand All @@ -53,9 +57,12 @@ func ResourceArtifactAllowlist() common.Resource {
}
return common.Resource{
Schema: allowlistSchema,
CustomizeDiff: func(ctx context.Context, d *schema.ResourceDiff) error {
return common.NamespaceCustomizeDiff(d)
},
Create: createOrUpdate,
Read: func(ctx context.Context, d *schema.ResourceData, c *common.DatabricksClient) error {
w, err := c.WorkspaceClient()
w, err := c.WorkspaceClientUnifiedProvider(ctx, d)
if err != nil {
return err
}
Expand All @@ -82,7 +89,7 @@ func ResourceArtifactAllowlist() common.Resource {
},
Update: createOrUpdate,
Delete: func(ctx context.Context, d *schema.ResourceData, c *common.DatabricksClient) error {
w, err := c.WorkspaceClient()
w, err := c.WorkspaceClientUnifiedProvider(ctx, d)
if err != nil {
return err
}
Expand Down
16 changes: 11 additions & 5 deletions catalog/resource_catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,13 @@ func ucDirectoryPathSlashAndEmptySuppressDiff(k, old, new string, d *schema.Reso
return false
}

type CatalogInfoResource struct {
catalog.CatalogInfo
common.Namespace
}

func ResourceCatalog() common.Resource {
catalogSchema := common.StructToSchema(catalog.CatalogInfo{},
catalogSchema := common.StructToSchema(CatalogInfoResource{},
func(s map[string]*schema.Schema) map[string]*schema.Schema {
s["force_destroy"] = &schema.Schema{
Type: schema.TypeBool,
Expand Down Expand Up @@ -58,12 +63,13 @@ func ResourceCatalog() common.Resource {
common.CustomizeSchemaPath(s, v).SetReadOnly()
}
common.CustomizeSchemaPath(s, "effective_predictive_optimization_flag").SetComputed().SetSuppressDiff()
common.NamespaceCustomizeSchemaMap(s)
return s
})
return common.Resource{
Schema: catalogSchema,
Create: func(ctx context.Context, d *schema.ResourceData, c *common.DatabricksClient) error {
w, err := c.WorkspaceClient()
w, err := c.WorkspaceClientUnifiedProvider(ctx, d)
if err != nil {
return err
}
Expand Down Expand Up @@ -107,7 +113,7 @@ func ResourceCatalog() common.Resource {
return bindings.AddCurrentWorkspaceBindings(ctx, d, w, ci.Name, bindings.BindingsSecurableTypeCatalog)
},
Read: func(ctx context.Context, d *schema.ResourceData, c *common.DatabricksClient) error {
w, err := c.WorkspaceClient()
w, err := c.WorkspaceClientUnifiedProvider(ctx, d)
if err != nil {
return err
}
Expand All @@ -119,7 +125,7 @@ func ResourceCatalog() common.Resource {
return common.StructToData(ci, catalogSchema, d)
},
Update: func(ctx context.Context, d *schema.ResourceData, c *common.DatabricksClient) error {
w, err := c.WorkspaceClient()
w, err := c.WorkspaceClientUnifiedProvider(ctx, d)
if err != nil {
return err
}
Expand Down Expand Up @@ -188,7 +194,7 @@ func ResourceCatalog() common.Resource {
return bindings.AddCurrentWorkspaceBindings(ctx, d, w, ci.Name, bindings.BindingsSecurableTypeCatalog)
},
Delete: func(ctx context.Context, d *schema.ResourceData, c *common.DatabricksClient) error {
w, err := c.WorkspaceClient()
w, err := c.WorkspaceClientUnifiedProvider(ctx, d)
if err != nil {
return err
}
Expand Down
19 changes: 14 additions & 5 deletions catalog/resource_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,13 @@ func suppressComputedFields(k, old, new string, d *schema.ResourceData) bool {
return false
}

type ConnectionInfoResource struct {
catalog.ConnectionInfo
common.Namespace
}

func ResourceConnection() common.Resource {
s := common.StructToSchema(catalog.ConnectionInfo{},
s := common.StructToSchema(ConnectionInfoResource{},
func(m map[string]*schema.Schema) map[string]*schema.Schema {
for _, v := range []string{"url", "metastore_id", "credential_type", "connection_id",
"created_at", "created_by", "full_name", "provisioning_info", "securable_type", "updated_at", "updated_by"} {
Expand All @@ -41,6 +46,7 @@ func ResourceConnection() common.Resource {
common.CustomizeSchemaPath(m, "options").SetSensitive().SetCustomSuppressDiff(suppressComputedFields)
common.CustomizeSchemaPath(m, "name").SetCustomSuppressDiff(common.EqualFoldDiffSuppress)

common.NamespaceCustomizeSchemaMap(m)
return m
})
pi := common.NewPairID("metastore_id", "name").Schema(
Expand All @@ -49,8 +55,11 @@ func ResourceConnection() common.Resource {
})
return common.Resource{
Schema: s,
CustomizeDiff: func(ctx context.Context, d *schema.ResourceDiff) error {
return common.NamespaceCustomizeDiff(d)
},
Create: func(ctx context.Context, d *schema.ResourceData, c *common.DatabricksClient) error {
w, err := c.WorkspaceClient()
w, err := c.WorkspaceClientUnifiedProvider(ctx, d)
if err != nil {
return err
}
Expand Down Expand Up @@ -79,7 +88,7 @@ func ResourceConnection() common.Resource {
return nil
},
Read: func(ctx context.Context, d *schema.ResourceData, c *common.DatabricksClient) error {
w, err := c.WorkspaceClient()
w, err := c.WorkspaceClientUnifiedProvider(ctx, d)
if err != nil {
return err
}
Expand Down Expand Up @@ -113,7 +122,7 @@ func ResourceConnection() common.Resource {
return common.StructToData(conn, s, d)
},
Update: func(ctx context.Context, d *schema.ResourceData, c *common.DatabricksClient) error {
w, err := c.WorkspaceClient()
w, err := c.WorkspaceClientUnifiedProvider(ctx, d)
if err != nil {
return err
}
Expand Down Expand Up @@ -161,7 +170,7 @@ func ResourceConnection() common.Resource {
return nil
},
Delete: func(ctx context.Context, d *schema.ResourceData, c *common.DatabricksClient) error {
w, err := c.WorkspaceClient()
w, err := c.WorkspaceClientUnifiedProvider(ctx, d)
if err != nil {
return err
}
Expand Down
19 changes: 14 additions & 5 deletions catalog/resource_credential.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

var credentialSchema = common.StructToSchema(catalog.CredentialInfo{},
type CredentialInfoResource struct {
catalog.CredentialInfo
common.Namespace
}

var credentialSchema = common.StructToSchema(CredentialInfoResource{},
func(m map[string]*schema.Schema) map[string]*schema.Schema {
var alofServiceCreds = []string{"aws_iam_role", "azure_managed_identity", "azure_service_principal",
"databricks_gcp_service_account"}
Expand Down Expand Up @@ -55,14 +60,18 @@ var credentialSchema = common.StructToSchema(catalog.CredentialInfo{},
Computed: true,
}
m["name"].DiffSuppressFunc = common.EqualFoldDiffSuppress
common.NamespaceCustomizeSchemaMap(m)
return m
})

func ResourceCredential() common.Resource {
return common.Resource{
Schema: credentialSchema,
CustomizeDiff: func(ctx context.Context, d *schema.ResourceDiff) error {
return common.NamespaceCustomizeDiff(d)
},
Create: func(ctx context.Context, d *schema.ResourceData, c *common.DatabricksClient) error {
w, err := c.WorkspaceClient()
w, err := c.WorkspaceClientUnifiedProvider(ctx, d)
if err != nil {
return err
}
Expand Down Expand Up @@ -94,7 +103,7 @@ func ResourceCredential() common.Resource {
return bindings.AddCurrentWorkspaceBindings(ctx, d, w, cred.Name, bindings.BindingsSecurableTypeCredential)
},
Read: func(ctx context.Context, d *schema.ResourceData, c *common.DatabricksClient) error {
w, err := c.WorkspaceClient()
w, err := c.WorkspaceClientUnifiedProvider(ctx, d)
if err != nil {
return err
}
Expand All @@ -115,7 +124,7 @@ func ResourceCredential() common.Resource {
},
Update: func(ctx context.Context, d *schema.ResourceData, c *common.DatabricksClient) error {
force := d.Get("force_update").(bool)
w, err := c.WorkspaceClient()
w, err := c.WorkspaceClientUnifiedProvider(ctx, d)
if err != nil {
return err
}
Expand Down Expand Up @@ -173,7 +182,7 @@ func ResourceCredential() common.Resource {
},
Delete: func(ctx context.Context, d *schema.ResourceData, c *common.DatabricksClient) error {
force := d.Get("force_destroy").(bool)
w, err := c.WorkspaceClient()
w, err := c.WorkspaceClientUnifiedProvider(ctx, d)
if err != nil {
return err
}
Expand Down
13 changes: 9 additions & 4 deletions catalog/resource_external_location.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
type ExternalLocationInfo struct {
catalog.ExternalLocationInfo
SkipValidation bool `json:"skip_validation,omitempty"`
common.Namespace
}

func ResourceExternalLocation() common.Resource {
Expand Down Expand Up @@ -57,12 +58,16 @@ func ResourceExternalLocation() common.Resource {
common.CustomizeSchemaPath(m, "file_event_queue", "managed_aqs", "subscription_id").SetRequired()
common.CustomizeSchemaPath(m, "file_event_queue").SetMaxItems(1)

common.NamespaceCustomizeSchemaMap(m)
return m
})
return common.Resource{
Schema: s,
CustomizeDiff: func(ctx context.Context, d *schema.ResourceDiff) error {
return common.NamespaceCustomizeDiff(d)
},
Create: func(ctx context.Context, d *schema.ResourceData, c *common.DatabricksClient) error {
w, err := c.WorkspaceClient()
w, err := c.WorkspaceClientUnifiedProvider(ctx, d)
if err != nil {
return err
}
Expand Down Expand Up @@ -95,7 +100,7 @@ func ResourceExternalLocation() common.Resource {
return bindings.AddCurrentWorkspaceBindings(ctx, d, w, el.Name, bindings.BindingsSecurableTypeExternalLocation)
},
Read: func(ctx context.Context, d *schema.ResourceData, c *common.DatabricksClient) error {
w, err := c.WorkspaceClient()
w, err := c.WorkspaceClientUnifiedProvider(ctx, d)
if err != nil {
return err
}
Expand All @@ -107,7 +112,7 @@ func ResourceExternalLocation() common.Resource {
},
Update: func(ctx context.Context, d *schema.ResourceData, c *common.DatabricksClient) error {
force := d.Get("force_update").(bool)
w, err := c.WorkspaceClient()
w, err := c.WorkspaceClientUnifiedProvider(ctx, d)
if err != nil {
return err
}
Expand Down Expand Up @@ -184,7 +189,7 @@ func ResourceExternalLocation() common.Resource {
},
Delete: func(ctx context.Context, d *schema.ResourceData, c *common.DatabricksClient) error {
force := d.Get("force_destroy").(bool)
w, err := c.WorkspaceClient()
w, err := c.WorkspaceClientUnifiedProvider(ctx, d)
if err != nil {
return err
}
Expand Down
17 changes: 13 additions & 4 deletions catalog/resource_grant.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,13 @@ func parseSecurableId(d *schema.ResourceData) (string, string, string, error) {
return split[0], split[1], split[2], nil
}

type GrantResource struct {
permissions.UnityCatalogPrivilegeAssignment
common.Namespace
}

func ResourceGrant() common.Resource {
s := common.StructToSchema(permissions.UnityCatalogPrivilegeAssignment{},
s := common.StructToSchema(GrantResource{},
func(m map[string]*schema.Schema) map[string]*schema.Schema {
common.CustomizeSchemaPath(m, "principal").SetForceNew()

Expand All @@ -155,13 +160,17 @@ func ResourceGrant() common.Resource {
ConflictsWith: permissions.SliceWithoutString(allFields, field),
}
}
common.NamespaceCustomizeSchemaMap(m)
return m
})

return common.Resource{
Schema: s,
CustomizeDiff: func(ctx context.Context, d *schema.ResourceDiff) error {
return common.NamespaceCustomizeDiff(d)
},
Create: func(ctx context.Context, d *schema.ResourceData, c *common.DatabricksClient) error {
w, err := c.WorkspaceClient()
w, err := c.WorkspaceClientUnifiedProvider(ctx, d)
if err != nil {
return err
}
Expand Down Expand Up @@ -208,7 +217,7 @@ func ResourceGrant() common.Resource {
return d.Set(securable, name)
},
Update: func(ctx context.Context, d *schema.ResourceData, c *common.DatabricksClient) error {
w, err := c.WorkspaceClient()
w, err := c.WorkspaceClientUnifiedProvider(ctx, d)
if err != nil {
return err
}
Expand All @@ -233,7 +242,7 @@ func ResourceGrant() common.Resource {
return replacePermissionsForPrincipal(unityCatalogPermissionsAPI, securable, name, principal, grants)
},
Delete: func(ctx context.Context, d *schema.ResourceData, c *common.DatabricksClient) error {
w, err := c.WorkspaceClient()
w, err := c.WorkspaceClientUnifiedProvider(ctx, d)
if err != nil {
return err
}
Expand Down
Loading
Loading