Skip to content

Commit b533bb2

Browse files
[Internal] Update Go SDK to 0.54.0 (#4328)
## Changes Update Go SDK to 0.54.0 ## Tests <!-- How is this tested? Please see the checklist below and also describe any other relevant tests --> - [X] `make test` run locally - [X] relevant change in `docs/` folder - [X] covered with integration tests in `internal/acceptance` - [X] using Go SDK - [ ] using TF Plugin Framework --------- Co-authored-by: Alex Ott <[email protected]>
1 parent 909b189 commit b533bb2

File tree

13 files changed

+1509
-189
lines changed

13 files changed

+1509
-189
lines changed

.codegen/_openapi_sha

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7016dcbf2e011459416cf408ce21143bcc4b3a25
1+
a6a317df8327c9b1e5cb59a03a42ffa2aabeef6d

catalog/resource_credential.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ func ResourceCredential() common.Resource {
8888
}
8989

9090
// Bind the current workspace if the credential is isolated, otherwise the read will fail
91-
return bindings.AddCurrentWorkspaceBindings(ctx, d, w, cred.Name, catalog.UpdateBindingsSecurableTypeServiceCredential)
91+
return bindings.AddCurrentWorkspaceBindings(ctx, d, w, cred.Name, catalog.UpdateBindingsSecurableTypeCredential)
9292
},
9393
Read: func(ctx context.Context, d *schema.ResourceData, c *common.DatabricksClient) error {
9494
w, err := c.WorkspaceClient()
@@ -155,7 +155,7 @@ func ResourceCredential() common.Resource {
155155
return err
156156
}
157157
// Bind the current workspace if the credential is isolated, otherwise the read will fail
158-
return bindings.AddCurrentWorkspaceBindings(ctx, d, w, updateCredRequest.NameArg, catalog.UpdateBindingsSecurableTypeServiceCredential)
158+
return bindings.AddCurrentWorkspaceBindings(ctx, d, w, updateCredRequest.NameArg, catalog.UpdateBindingsSecurableTypeCredential)
159159
},
160160
Delete: func(ctx context.Context, d *schema.ResourceData, c *common.DatabricksClient) error {
161161
force := d.Get("force_destroy").(bool)

catalog/resource_credential_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func TestCreateIsolatedCredential(t *testing.T) {
110110
}, nil)
111111
w.GetMockWorkspaceBindingsAPI().EXPECT().UpdateBindings(mock.Anything, catalog.UpdateWorkspaceBindingsParameters{
112112
SecurableName: "a",
113-
SecurableType: catalog.UpdateBindingsSecurableTypeServiceCredential,
113+
SecurableType: catalog.UpdateBindingsSecurableTypeCredential,
114114
Add: []catalog.WorkspaceBinding{
115115
{
116116
WorkspaceId: int64(123456789101112),

catalog/resource_workspace_binding.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,14 @@ func ResourceWorkspaceBinding() common.Resource {
4343
Optional: true,
4444
Default: "catalog",
4545
}
46-
common.CustomizeSchemaPath(m, "securable_type").SetValidateFunc(validation.StringInSlice([]string{"catalog", "external_location", "storage_credential"}, false))
47-
common.CustomizeSchemaPath(m, "binding_type").SetDefault(catalog.WorkspaceBindingBindingTypeBindingTypeReadWrite).SetValidateFunc(validation.StringInSlice([]string{
48-
string(catalog.WorkspaceBindingBindingTypeBindingTypeReadWrite),
49-
string(catalog.WorkspaceBindingBindingTypeBindingTypeReadOnly),
50-
}, false))
46+
common.CustomizeSchemaPath(m, "securable_type").SetValidateFunc(validation.StringInSlice([]string{
47+
"catalog", "external_location", "storage_credential", "credential"}, false))
48+
common.CustomizeSchemaPath(m, "binding_type").SetDefault(
49+
catalog.WorkspaceBindingBindingTypeBindingTypeReadWrite).SetValidateFunc(
50+
validation.StringInSlice([]string{
51+
string(catalog.WorkspaceBindingBindingTypeBindingTypeReadWrite),
52+
string(catalog.WorkspaceBindingBindingTypeBindingTypeReadOnly),
53+
}, false))
5154
return m
5255
},
5356
)

docs/resources/workspace_binding.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ If you use workspaces to isolate user data access, you may want to limit access
99

1010
By default, Databricks assigns the securable to all workspaces attached to the current metastore. By using `databricks_workspace_binding`, the securable will be unassigned from all workspaces and only assigned explicitly using this resource.
1111

12-
-> To use this resource the securable must have its isolation mode set to `ISOLATED` (for [databricks_catalog](catalog.md)) or `ISOLATION_MODE_ISOLATED` (for (for [databricks_external_location](external_location.md) or [databricks_storage_credential](storage_credential.md)) for the `isolation_mode` attribute. Alternatively, the isolation mode can be set using the UI or API by following [this guide](https://docs.databricks.com/data-governance/unity-catalog/create-catalogs.html#configuration), [this guide](https://docs.databricks.com/en/connect/unity-catalog/external-locations.html#workspace-binding) or [this guide](https://docs.databricks.com/en/connect/unity-catalog/storage-credentials.html#optional-assign-a-storage-credential-to-specific-workspaces).
12+
-> To use this resource the securable must have its isolation mode set to `ISOLATED` (for [databricks_catalog](catalog.md)) or `ISOLATION_MODE_ISOLATED` (for (for [databricks_external_location](external_location.md), [databricks_storage_credential](storage_credential.md) or [databricks_credential](credential.md)) for the `isolation_mode` attribute. Alternatively, the isolation mode can be set using the UI or API by following [this guide](https://docs.databricks.com/data-governance/unity-catalog/create-catalogs.html#configuration), [this guide](https://docs.databricks.com/en/connect/unity-catalog/external-locations.html#workspace-binding) or [this guide](https://docs.databricks.com/en/connect/unity-catalog/storage-credentials.html#optional-assign-a-storage-credential-to-specific-workspaces).
1313

1414
-> If the securable's isolation mode was set to `ISOLATED` using Terraform then the securable will have been automatically bound to the workspace it was created from.
1515

@@ -33,7 +33,7 @@ The following arguments are required:
3333

3434
* `workspace_id` - ID of the workspace. Change forces creation of a new resource.
3535
* `securable_name` - Name of securable. Change forces creation of a new resource.
36-
* `securable_type` - Type of securable. Can be `catalog`, `external-location` or `storage-credential`. Default to `catalog`. Change forces creation of a new resource.
36+
* `securable_type` - Type of securable. Can be `catalog`, `external_location`, `storage_credential` or `credential`. Default to `catalog`. Change forces creation of a new resource.
3737
* `binding_type` - (Optional) Binding mode. Default to `BINDING_TYPE_READ_WRITE`. Possible values are `BINDING_TYPE_READ_ONLY`, `BINDING_TYPE_READ_WRITE`.
3838

3939
## Import

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.22.0
55
toolchain go1.22.5
66

77
require (
8-
github.com/databricks/databricks-sdk-go v0.53.0
8+
github.com/databricks/databricks-sdk-go v0.54.0
99
github.com/golang-jwt/jwt/v4 v4.5.1
1010
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320
1111
github.com/hashicorp/hcl v1.0.0

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53E
2828
github.com/cyphar/filepath-securejoin v0.2.4/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4=
2929
github.com/databricks/databricks-sdk-go v0.53.0 h1:rZMXaTC3HNKZt+m4C4I/dY3EdZj+kl/sVd/Kdq55Qfo=
3030
github.com/databricks/databricks-sdk-go v0.53.0/go.mod h1:ds+zbv5mlQG7nFEU5ojLtgN/u0/9YzZmKQES/CfedzU=
31+
github.com/databricks/databricks-sdk-go v0.54.0 h1:L8gsA3NXs+uYU3QtW/OUgjxMQxOH24k0MT9JhB3zLlM=
32+
github.com/databricks/databricks-sdk-go v0.54.0/go.mod h1:ds+zbv5mlQG7nFEU5ojLtgN/u0/9YzZmKQES/CfedzU=
3133
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
3234
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
3335
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=

internal/acceptance/workspace_binding_test.go

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,16 @@ func workspaceBindingTemplateWithWorkspaceId(workspaceId string) string {
3030
}
3131
isolation_mode = "ISOLATION_MODE_ISOLATED"
3232
}
33+
34+
resource "databricks_credential" "credential" {
35+
name = "service-cred-{var.RANDOM}"
36+
aws_iam_role {
37+
role_arn = "{env.TEST_METASTORE_DATA_ACCESS_ARN}"
38+
}
39+
purpose = "SERVICE"
40+
skip_validation = true
41+
isolation_mode = "ISOLATION_MODE_ISOLATED"
42+
}
3343
3444
resource "databricks_external_location" "some" {
3545
name = "external-{var.RANDOM}"
@@ -40,28 +50,34 @@ func workspaceBindingTemplateWithWorkspaceId(workspaceId string) string {
4050
4151
resource "databricks_workspace_binding" "dev" {
4252
catalog_name = databricks_catalog.dev.name
43-
workspace_id = %s
53+
workspace_id = %[1]s
4454
}
4555
4656
resource "databricks_workspace_binding" "prod" {
4757
securable_name = databricks_catalog.prod.name
4858
securable_type = "catalog"
49-
workspace_id = %s
59+
workspace_id = %[1]s
5060
binding_type = "BINDING_TYPE_READ_ONLY"
5161
}
5262
5363
resource "databricks_workspace_binding" "ext" {
5464
securable_name = databricks_external_location.some.id
5565
securable_type = "external_location"
56-
workspace_id = %s
66+
workspace_id = %[1]s
5767
}
5868
5969
resource "databricks_workspace_binding" "cred" {
6070
securable_name = databricks_storage_credential.external.id
6171
securable_type = "storage_credential"
62-
workspace_id = %s
63-
}
64-
`, workspaceId, workspaceId, workspaceId, workspaceId)
72+
workspace_id = %[1]s
73+
}
74+
75+
resource "databricks_workspace_binding" "service_cred" {
76+
securable_name = databricks_credential.credential.id
77+
securable_type = "credential"
78+
workspace_id = %[1]s
79+
}
80+
`, workspaceId)
6581
}
6682

6783
func TestUcAccWorkspaceBindingToOtherWorkspace(t *testing.T) {

0 commit comments

Comments
 (0)