-
Notifications
You must be signed in to change notification settings - Fork 388
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature] WIP: Allow to skip calling Read after Create/Update operations #4173
base: main
Are you sure you want to change the base?
Conversation
workspace/resource_notebook.go
Outdated
} | ||
if err != nil { | ||
return err | ||
} | ||
} | ||
d.Set("object_id", resp.ObjectID) | ||
d.Set("skip_get_status", true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of adding this to the databricks_notebook
schema, can we add it to common.Resource
when defining the resource? Basically, we can change the create method to:
resource.CreateContext = func(ctx context.Context, d *schema.ResourceData, m any) diag.Diagnostics {
c := m.(*DatabricksClient)
err := recoverable(r.Create)(ctx, d, c)
if err != nil {
err = nicerError(ctx, err, "create")
return diag.FromErr(err)
}
if r.SkipReadAfterCreateAndUpdate {
return nil
}
if err = recoverable(r.Read)(ctx, d, c); err != nil {
err = nicerError(ctx, err, "read")
return diag.FromErr(err)
}
return nil
}
and same for update.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let me look
get-status
for notebooks in Read after Create/Update operationsThis PR adds the ability for a resource to specify that it may not need to call `Read` after `Create` and `Update` operations so we can avoid performing another API call(s). The resource may implement `CanSkipReadAfterCreateAndUpdate` function that can decide if the Read operation should be skipped. It was found that the import API returns `object_id` as a result of its execution, so we don't really need to call get-status to fill all attributes. This should help when we import a large number of notebooks, i.e., when applying exported resources.
7ecd15c
to
2ddb757
Compare
Test Details: go/deco-tests/11598800362 |
Changes
This PR adds the ability for a resource to specify that it may not need to call
Read
after Create and Update operations so we can avoid performing another API call(s). The resource may implementCanSkipReadAfterCreateAndUpdate
function that can decide if theRead
operation should be skipped.It was found that the
import
API returnsobject_id
as a result of its execution, so we don't really need to callget-status
to fill all attributes. This should help when we import a large number of notebooks, i.e., when applying exported resources.TODOs:
language
attributeTests
make test
run locallyrelevant change indocs/
folderinternal/acceptance
using Go SDK