Skip to content

Commit 4b0f2ff

Browse files
authored
Fix databricks_metastore_data_access and databricks_storage_credential creation on GCP (#2712)
* fix * fix test
1 parent c0b8bc1 commit 4b0f2ff

File tree

4 files changed

+21
-8
lines changed

4 files changed

+21
-8
lines changed

catalog/resource_metastore_data_access.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ func ResourceMetastoreDataAccess() *schema.Resource {
9797
var create catalog.CreateStorageCredential
9898
common.DataToStructPointer(d, tmpSchema, &create)
9999

100+
//manually add empty struct back for databricks_gcp_service_account
101+
if _, ok := d.GetOk("databricks_gcp_service_account"); ok {
102+
create.DatabricksGcpServiceAccount = struct{}{}
103+
}
104+
100105
return c.AccountOrWorkspaceRequest(func(acc *databricks.AccountClient) error {
101106
dac, err := acc.StorageCredentials.Create(ctx,
102107
catalog.AccountsCreateStorageCredential{

catalog/resource_metastore_data_access_test.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,9 @@ func TestCreateDacWithDbGcpSA(t *testing.T) {
129129
{
130130
Method: "POST",
131131
Resource: "/api/2.1/unity-catalog/storage-credentials",
132-
ExpectedRequest: DataAccessConfiguration{
133-
Name: "bcd",
132+
ExpectedRequest: catalog.CreateStorageCredential{
133+
Name: "bcd",
134+
DatabricksGcpServiceAccount: struct{}{},
134135
},
135136
Response: catalog.StorageCredentialInfo{
136137
Id: "bcd",
@@ -149,9 +150,9 @@ func TestCreateDacWithDbGcpSA(t *testing.T) {
149150
{
150151
Method: "GET",
151152
Resource: "/api/2.1/unity-catalog/storage-credentials/bcd?",
152-
Response: DataAccessConfiguration{
153+
Response: catalog.StorageCredentialInfo{
153154
Name: "bcd",
154-
DBGcpSA: &DbGcpServiceAccount{
155+
DatabricksGcpServiceAccount: &catalog.DatabricksGcpServiceAccountResponse{
155156
156157
},
157158
},
@@ -314,7 +315,8 @@ func TestCreateAccountDacWithDbGcpSA(t *testing.T) {
314315
ExpectedRequest: catalog.AccountsCreateStorageCredential{
315316
MetastoreId: "abc",
316317
CredentialInfo: &catalog.CreateStorageCredential{
317-
Name: "bcd",
318+
Name: "bcd",
319+
DatabricksGcpServiceAccount: struct{}{},
318320
},
319321
},
320322
Response: catalog.AccountsStorageCredentialInfo{

catalog/resource_storage_credential.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ func ResourceStorageCredential() *schema.Resource {
5252
common.DataToStructPointer(d, tmpSchema, &create)
5353
common.DataToStructPointer(d, tmpSchema, &update)
5454

55+
//manually add empty struct back for databricks_gcp_service_account
56+
if _, ok := d.GetOk("databricks_gcp_service_account"); ok {
57+
create.DatabricksGcpServiceAccount = struct{}{}
58+
}
59+
5560
return c.AccountOrWorkspaceRequest(func(acc *databricks.AccountClient) error {
5661
storageCredential, err := acc.StorageCredentials.Create(ctx,
5762
catalog.AccountsCreateStorageCredential{

catalog/resource_storage_credential_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -323,9 +323,10 @@ func TestCreateStorageCredentialWithDbGcpSA(t *testing.T) {
323323
{
324324
Method: "POST",
325325
Resource: "/api/2.1/unity-catalog/storage-credentials",
326-
ExpectedRequest: StorageCredentialInfo{
327-
Name: "a",
328-
Comment: "c",
326+
ExpectedRequest: catalog.CreateStorageCredential{
327+
Name: "a",
328+
DatabricksGcpServiceAccount: struct{}{},
329+
Comment: "c",
329330
},
330331
Response: catalog.StorageCredentialInfo{
331332
Name: "a",

0 commit comments

Comments
 (0)