Skip to content

Commit

Permalink
Temporary workaround until OpenAPI spec is fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
alexott committed Dec 10, 2024
1 parent 528e729 commit 70e624f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions catalog/resource_credential.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ var credentialSchema = common.StructToSchema(catalog.CredentialInfo{},
return m
})

// This is a custom securable type for credential - remove after OpenAPI spec is fixed.
const UpdateBindingsSecurableTypeCredential catalog.UpdateBindingsSecurableType = `credential`

func ResourceCredential() common.Resource {
return common.Resource{
Schema: credentialSchema,
Expand Down Expand Up @@ -83,7 +86,7 @@ func ResourceCredential() common.Resource {
}

// Bind the current workspace if the credential is isolated, otherwise the read will fail
return bindings.AddCurrentWorkspaceBindings(ctx, d, w, cred.Name, catalog.UpdateBindingsSecurableTypeServiceCredential)
return bindings.AddCurrentWorkspaceBindings(ctx, d, w, cred.Name, UpdateBindingsSecurableTypeCredential)
},
Read: func(ctx context.Context, d *schema.ResourceData, c *common.DatabricksClient) error {
w, err := c.WorkspaceClient()
Expand Down Expand Up @@ -150,7 +153,7 @@ func ResourceCredential() common.Resource {
return err
}
// Bind the current workspace if the credential is isolated, otherwise the read will fail
return bindings.AddCurrentWorkspaceBindings(ctx, d, w, updateCredRequest.NameArg, catalog.UpdateBindingsSecurableTypeServiceCredential)
return bindings.AddCurrentWorkspaceBindings(ctx, d, w, updateCredRequest.NameArg, UpdateBindingsSecurableTypeCredential)
},
Delete: func(ctx context.Context, d *schema.ResourceData, c *common.DatabricksClient) error {
force := d.Get("force_destroy").(bool)
Expand Down
2 changes: 1 addition & 1 deletion catalog/resource_credential_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func TestCreateIsolatedCredential(t *testing.T) {
}, nil)
w.GetMockWorkspaceBindingsAPI().EXPECT().UpdateBindings(mock.Anything, catalog.UpdateWorkspaceBindingsParameters{
SecurableName: "a",
SecurableType: catalog.UpdateBindingsSecurableTypeServiceCredential,
SecurableType: UpdateBindingsSecurableTypeCredential,
Add: []catalog.WorkspaceBinding{
{
WorkspaceId: int64(123456789101112),
Expand Down

0 comments on commit 70e624f

Please sign in to comment.