Skip to content

Commit 259cca8

Browse files
authored
[Internal] Bump Go SDK & Generate Latest TF Structs (#4706)
## Changes <!-- Summary of your changes that are easy to understand --> ## Tests <!-- How is this tested? Please see the checklist below and also describe any other relevant tests --> - [ ] `make test` run locally - [ ] relevant change in `docs/` folder - [ ] covered with integration tests in `internal/acceptance` - [ ] using Go SDK - [ ] using TF Plugin Framework NO_CHANGELOG=true --------- Co-authored-by: Omer Lachish <[email protected]>
1 parent 240a44d commit 259cca8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+7797
-1426
lines changed

.codegen/_openapi_sha

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
d4c86c045ee9d0410a41ef07e8ae708673b95fa1
1+
6b2dbf5489ec706709fed80ee65caed7d10a2f38

.gitattributes

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ common/reflect_resource.go linguist-generated=true
77
common/resource.go linguist-generated=true
88
common/tracking_context.go linguist-generated=true
99
common/util.go linguist-generated=true
10+
docs/data-sources/alert_v2.md linguist-generated=true
11+
docs/data-sources/alerts_v2.md linguist-generated=true
12+
docs/data-sources/budget_policies.md linguist-generated=true
13+
docs/data-sources/budget_policy.md linguist-generated=true
14+
docs/data-sources/database_instance.md linguist-generated=true
15+
docs/data-sources/database_instances.md linguist-generated=true
16+
docs/resources/alert_v2.md linguist-generated=true
17+
docs/resources/budget_policy.md linguist-generated=true
18+
docs/resources/database_instance.md linguist-generated=true
1019
internal/providers/common/common.go linguist-generated=true
1120
internal/providers/pluginfw/auto_generation.go linguist-generated=true
1221
internal/providers/pluginfw/autogen/helpers.go linguist-generated=true
@@ -24,6 +33,9 @@ internal/providers/pluginfw/products/alert_v2/resource_alert_v2.go linguist-gene
2433
internal/providers/pluginfw/products/budget_policy/data_budget_policies.go linguist-generated=true
2534
internal/providers/pluginfw/products/budget_policy/data_budget_policy.go linguist-generated=true
2635
internal/providers/pluginfw/products/budget_policy/resource_budget_policy.go linguist-generated=true
36+
internal/providers/pluginfw/products/database_instance/data_database_instance.go linguist-generated=true
37+
internal/providers/pluginfw/products/database_instance/data_database_instances.go linguist-generated=true
38+
internal/providers/pluginfw/products/database_instance/resource_database_instance.go linguist-generated=true
2739
internal/providers/pluginfw/tfschema/attribute_builder.go linguist-generated=true
2840
internal/providers/pluginfw/tfschema/attribute_converter.go linguist-generated=true
2941
internal/providers/pluginfw/tfschema/base_schema_builder.go linguist-generated=true

catalog/bindings/bindings.go

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,39 @@ package bindings
22

33
import (
44
"context"
5+
"fmt"
56

67
"github.com/databricks/databricks-sdk-go"
78
"github.com/databricks/databricks-sdk-go/service/catalog"
89
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
910
)
1011

11-
func AddCurrentWorkspaceBindings(ctx context.Context, d *schema.ResourceData, w *databricks.WorkspaceClient, securableName string, securableType catalog.UpdateBindingsSecurableType) error {
12+
type BindingsSecurableType string
13+
14+
const BindingsSecurableTypeCatalog BindingsSecurableType = `catalog`
15+
const BindingsSecurableTypeCredential BindingsSecurableType = `credential`
16+
const BindingsSecurableTypeExternalLocation BindingsSecurableType = `external_location`
17+
const BindingsSecurableTypeStorageCredential BindingsSecurableType = `storage_credential`
18+
19+
func (f *BindingsSecurableType) String() string {
20+
return string(*f)
21+
}
22+
23+
func (f *BindingsSecurableType) Set(v string) error {
24+
switch v {
25+
case `catalog`, `credential`, `external_location`, `storage_credential`:
26+
*f = BindingsSecurableType(v)
27+
return nil
28+
default:
29+
return fmt.Errorf(`value "%s" is not one of "catalog", "credential", "external_location", "storage_credential"`, v)
30+
}
31+
}
32+
33+
func (f *BindingsSecurableType) Type() string {
34+
return "BindingsSecurableType"
35+
}
36+
37+
func AddCurrentWorkspaceBindings(ctx context.Context, d *schema.ResourceData, w *databricks.WorkspaceClient, securableName string, securableType BindingsSecurableType) error {
1238
if d.Get("isolation_mode") != "ISOLATED" && d.Get("isolation_mode") != "ISOLATION_MODE_ISOLATED" {
1339
return nil
1440
}
@@ -19,7 +45,7 @@ func AddCurrentWorkspaceBindings(ctx context.Context, d *schema.ResourceData, w
1945
}
2046
_, err = w.WorkspaceBindings.UpdateBindings(ctx, catalog.UpdateWorkspaceBindingsParameters{
2147
SecurableName: securableName,
22-
SecurableType: securableType,
48+
SecurableType: securableType.String(),
2349
Add: []catalog.WorkspaceBinding{
2450
{
2551
BindingType: catalog.WorkspaceBindingBindingTypeBindingTypeReadWrite,

catalog/resource_catalog.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ func ResourceCatalog() common.Resource {
102102
}
103103

104104
// Bind the current workspace if the catalog is isolated, otherwise the read will fail
105-
return bindings.AddCurrentWorkspaceBindings(ctx, d, w, ci.Name, catalog.UpdateBindingsSecurableTypeCatalog)
105+
return bindings.AddCurrentWorkspaceBindings(ctx, d, w, ci.Name, bindings.BindingsSecurableTypeCatalog)
106106
},
107107
Read: func(ctx context.Context, d *schema.ResourceData, c *common.DatabricksClient) error {
108108
w, err := c.WorkspaceClient()
@@ -183,7 +183,7 @@ func ResourceCatalog() common.Resource {
183183
d.SetId(ci.Name)
184184

185185
// Bind the current workspace if the catalog is isolated, otherwise the read will fail
186-
return bindings.AddCurrentWorkspaceBindings(ctx, d, w, ci.Name, catalog.UpdateBindingsSecurableTypeCatalog)
186+
return bindings.AddCurrentWorkspaceBindings(ctx, d, w, ci.Name, bindings.BindingsSecurableTypeCatalog)
187187
},
188188
Delete: func(ctx context.Context, d *schema.ResourceData, c *common.DatabricksClient) error {
189189
w, err := c.WorkspaceClient()

catalog/resource_catalog_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,7 @@ func TestCatalogCreateIsolated(t *testing.T) {
715715
BindingType: catalog.WorkspaceBindingBindingTypeBindingTypeReadWrite,
716716
},
717717
},
718-
}).Return(&catalog.WorkspaceBindingsResponse{
718+
}).Return(&catalog.UpdateWorkspaceBindingsResponse{
719719
Bindings: []catalog.WorkspaceBinding{
720720
{
721721
WorkspaceId: int64(123456789101112),

catalog/resource_catalog_workspace_binding_test.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55

66
"github.com/databricks/databricks-sdk-go/experimental/mocks"
77
"github.com/databricks/databricks-sdk-go/service/catalog"
8+
"github.com/databricks/terraform-provider-databricks/catalog/bindings"
89
"github.com/databricks/terraform-provider-databricks/qa"
910
"github.com/stretchr/testify/mock"
1011
)
@@ -27,17 +28,17 @@ func TestCatalogWorkspaceBindings_Create(t *testing.T) {
2728
},
2829
},
2930
SecurableName: "my_catalog",
30-
SecurableType: catalog.UpdateBindingsSecurableTypeCatalog,
31-
}).Return(&catalog.WorkspaceBindingsResponse{
31+
SecurableType: string(bindings.BindingsSecurableTypeCatalog),
32+
}).Return(&catalog.UpdateWorkspaceBindingsResponse{
3233
Bindings: []catalog.WorkspaceBinding{
3334
{
3435
BindingType: catalog.WorkspaceBindingBindingTypeBindingTypeReadWrite,
3536
WorkspaceId: int64(1234567890101112),
3637
},
3738
},
3839
}, nil)
39-
e.GetBindingsBySecurableTypeAndSecurableName(mock.Anything, catalog.GetBindingsSecurableTypeCatalog, "my_catalog").
40-
Return(&catalog.WorkspaceBindingsResponse{
40+
e.GetBindingsBySecurableTypeAndSecurableName(mock.Anything, string(bindings.BindingsSecurableTypeCatalog), "my_catalog").
41+
Return(&catalog.GetWorkspaceBindingsResponse{
4142
Bindings: []catalog.WorkspaceBinding{
4243
{
4344
BindingType: catalog.WorkspaceBindingBindingTypeBindingTypeReadWrite,
@@ -72,17 +73,17 @@ func TestCatalogWorkspaceBindingsReadOnly_Create(t *testing.T) {
7273
},
7374
},
7475
SecurableName: "my_catalog",
75-
SecurableType: catalog.UpdateBindingsSecurableTypeCatalog,
76-
}).Return(&catalog.WorkspaceBindingsResponse{
76+
SecurableType: string(bindings.BindingsSecurableTypeCatalog),
77+
}).Return(&catalog.UpdateWorkspaceBindingsResponse{
7778
Bindings: []catalog.WorkspaceBinding{
7879
{
7980
BindingType: catalog.WorkspaceBindingBindingTypeBindingTypeReadOnly,
8081
WorkspaceId: int64(1234567890101112),
8182
},
8283
},
8384
}, nil)
84-
e.GetBindingsBySecurableTypeAndSecurableName(mock.Anything, catalog.GetBindingsSecurableTypeCatalog, "my_catalog").
85-
Return(&catalog.WorkspaceBindingsResponse{
85+
e.GetBindingsBySecurableTypeAndSecurableName(mock.Anything, "catalog", "my_catalog").
86+
Return(&catalog.GetWorkspaceBindingsResponse{
8687
Bindings: []catalog.WorkspaceBinding{
8788
{
8889
BindingType: catalog.WorkspaceBindingBindingTypeBindingTypeReadOnly,
@@ -110,8 +111,8 @@ func TestCatalogWorkspaceBindingsReadImport(t *testing.T) {
110111
qa.ResourceFixture{
111112
MockWorkspaceClientFunc: func(w *mocks.MockWorkspaceClient) {
112113
w.GetMockWorkspaceBindingsAPI().EXPECT().
113-
GetBindingsBySecurableTypeAndSecurableName(mock.Anything, catalog.GetBindingsSecurableTypeCatalog, "my_catalog").
114-
Return(&catalog.WorkspaceBindingsResponse{
114+
GetBindingsBySecurableTypeAndSecurableName(mock.Anything, string(bindings.BindingsSecurableTypeCatalog), "my_catalog").
115+
Return(&catalog.GetWorkspaceBindingsResponse{
115116
Bindings: []catalog.WorkspaceBinding{
116117
{
117118
BindingType: catalog.WorkspaceBindingBindingTypeBindingTypeReadOnly,

catalog/resource_credential.go

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

9393
// Bind the current workspace if the credential is isolated, otherwise the read will fail
94-
return bindings.AddCurrentWorkspaceBindings(ctx, d, w, cred.Name, catalog.UpdateBindingsSecurableTypeCredential)
94+
return bindings.AddCurrentWorkspaceBindings(ctx, d, w, cred.Name, bindings.BindingsSecurableTypeCredential)
9595
},
9696
Read: func(ctx context.Context, d *schema.ResourceData, c *common.DatabricksClient) error {
9797
w, err := c.WorkspaceClient()
@@ -169,7 +169,7 @@ func ResourceCredential() common.Resource {
169169
return err
170170
}
171171
// Bind the current workspace if the credential is isolated, otherwise the read will fail
172-
return bindings.AddCurrentWorkspaceBindings(ctx, d, w, updateCredRequest.NameArg, catalog.UpdateBindingsSecurableTypeCredential)
172+
return bindings.AddCurrentWorkspaceBindings(ctx, d, w, updateCredRequest.NameArg, bindings.BindingsSecurableTypeCredential)
173173
},
174174
Delete: func(ctx context.Context, d *schema.ResourceData, c *common.DatabricksClient) error {
175175
force := d.Get("force_destroy").(bool)

catalog/resource_credential_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55

66
"github.com/databricks/databricks-sdk-go/experimental/mocks"
77
"github.com/databricks/databricks-sdk-go/service/catalog"
8+
"github.com/databricks/terraform-provider-databricks/catalog/bindings"
89
"github.com/databricks/terraform-provider-databricks/qa"
910
"github.com/stretchr/testify/mock"
1011
)
@@ -110,14 +111,14 @@ func TestCreateIsolatedCredential(t *testing.T) {
110111
}, nil)
111112
w.GetMockWorkspaceBindingsAPI().EXPECT().UpdateBindings(mock.Anything, catalog.UpdateWorkspaceBindingsParameters{
112113
SecurableName: "a",
113-
SecurableType: catalog.UpdateBindingsSecurableTypeCredential,
114+
SecurableType: string(bindings.BindingsSecurableTypeCredential),
114115
Add: []catalog.WorkspaceBinding{
115116
{
116117
WorkspaceId: int64(123456789101112),
117118
BindingType: catalog.WorkspaceBindingBindingTypeBindingTypeReadWrite,
118119
},
119120
},
120-
}).Return(&catalog.WorkspaceBindingsResponse{
121+
}).Return(&catalog.UpdateWorkspaceBindingsResponse{
121122
Bindings: []catalog.WorkspaceBinding{
122123
{
123124
WorkspaceId: int64(123456789101112),

catalog/resource_external_location.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func ResourceExternalLocation() common.Resource {
7373
}
7474

7575
// Bind the current workspace if the external location is isolated, otherwise the read will fail
76-
return bindings.AddCurrentWorkspaceBindings(ctx, d, w, el.Name, catalog.UpdateBindingsSecurableTypeExternalLocation)
76+
return bindings.AddCurrentWorkspaceBindings(ctx, d, w, el.Name, bindings.BindingsSecurableTypeExternalLocation)
7777
},
7878
Read: func(ctx context.Context, d *schema.ResourceData, c *common.DatabricksClient) error {
7979
w, err := c.WorkspaceClient()
@@ -137,7 +137,7 @@ func ResourceExternalLocation() common.Resource {
137137
return err
138138
}
139139
// Bind the current workspace if the external location is isolated, otherwise the read will fail
140-
return bindings.AddCurrentWorkspaceBindings(ctx, d, w, updateExternalLocationRequest.Name, catalog.UpdateBindingsSecurableTypeExternalLocation)
140+
return bindings.AddCurrentWorkspaceBindings(ctx, d, w, updateExternalLocationRequest.Name, bindings.BindingsSecurableTypeExternalLocation)
141141
},
142142
Delete: func(ctx context.Context, d *schema.ResourceData, c *common.DatabricksClient) error {
143143
force := d.Get("force_destroy").(bool)

catalog/resource_external_location_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ func TestCreateIsolatedExternalLocation(t *testing.T) {
9999
BindingType: catalog.WorkspaceBindingBindingTypeBindingTypeReadWrite,
100100
},
101101
},
102-
}).Return(&catalog.WorkspaceBindingsResponse{
102+
}).Return(&catalog.UpdateWorkspaceBindingsResponse{
103103
Bindings: []catalog.WorkspaceBinding{
104104
{
105105
WorkspaceId: int64(123456789101112),

0 commit comments

Comments
 (0)