-
Notifications
You must be signed in to change notification settings - Fork 401
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
[Internal] Migrate Share Data Source to Plugin Framework #4161
Conversation
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.
Why do we need to do staging for data sources? Imho it's less critical than resources.
but the main issue IMHO is that we modify the acceptance tests to work only with the staged resources, and leaving a hole in acceptance testing of "normal" data sources
attrs, blocks := tfschema.DataSourceStructToSchemaMap(sharing_tf.ShareInfo{}, nil) | ||
resp.Schema = schema.Schema{ | ||
Attributes: attrs, | ||
Blocks: blocks, | ||
} |
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.
It's not a direct problem, but such code is repeated everywhere. Should we add a helper function that we can use instead?
58c0ba5
to
2235d30
Compare
@rauchy I think that it makes sense just to duplicate tests, not to replace resources/data sources, so we keep tests for SDK-based resources as well, and remove the duplicate tests when we replace SDK-based with plugin framework-based |
@alexott that was exactly what I was about to propose :) |
227dbb6
to
74ad0f6
Compare
} | ||
|
||
func (d *ShareDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { | ||
resp.TypeName = pluginfwcommon.GetDatabricksStagingName("share") |
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.
nit: We should abstract this out above like: https://github.com/databricks/terraform-provider-databricks/blob/main/internal/providers/pluginfw/resources/volume/data_volumes.go#L19
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.
See my comment below.
Name: config.Name.ValueString(), | ||
IncludeSharedData: true, | ||
}) | ||
if err != nil { |
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.
We should remove from state if missing:
if apierr.IsMissing(err) {
resp.State.RemoveResource(ctx)
}
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.
Good to know that's needed :) b7c32b7
} | ||
|
||
func (d *SharesDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { | ||
resp.TypeName = pluginfwcommon.GetDatabricksStagingName("shares") |
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.
Same here
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.
Initially, I planned to use a dataSourceName
constant for both the share and shares data sources. However, since they share the same namespace, that wasn’t an option. So, I just included the constant within the Metadata
function, particularly since it’s only used once in each data source. Alternatively, I could assign a dataSourceName
constant to one data source and rename it for the other, but that didn't feel quite right.
Let me know if you have a preferred approach.
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.
I see, yeah we could use dataSourceNameShare, dataSourceNameShares, mentioning this because we would also need to set the useragent (eg: https://github.com/databricks/terraform-provider-databricks/blob/main/internal/providers/pluginfw/resources/volume/data_volumes.go#L56) and use the same name there as well so might be better to abstract this in a single variable.
74ad0f6
to
b7c32b7
Compare
b7c32b7
to
7e28bac
Compare
Test Details: go/deco-tests/11591746843 |
### New Features and Improvements * Added `databricks_functions` data source ([#4154](#4154)). ### Bug Fixes * Handle edge case for `effective_properties` in `databricks_sql_table` ([#4153](#4153)). * Provide more prescriptive error when users fail to create a single node cluster ([#4168](#4168)). ### Internal Changes * Add test instructions for external contributors ([#4169](#4169)). * Always write message for manual test integration ([#4188](#4188)). * Make `Read` after `Create`/`Update` configurable ([#4190](#4190)). * Migrate Share Data Source to Plugin Framework ([#4161](#4161)). * Migrate Share Resource to Plugin Framework ([#4047](#4047)). * Rollout Plugin Framework ([#4134](#4134)). ### Dependency Updates * Bump Go SDK to v0.50.0 ([#4178](#4178)). ### Exporter * Allow to match resource names by regular expression ([#4177](#4177)).
### New Features and Improvements * Added `databricks_functions` data source ([#4154](#4154)). ### Bug Fixes * Handle edge case for `effective_properties` in `databricks_sql_table` ([#4153](#4153)). * Provide more prescriptive error when users fail to create a single node cluster ([#4168](#4168)). ### Internal Changes * Add test instructions for external contributors ([#4169](#4169)). * Always write message for manual test integration ([#4188](#4188)). * Make `Read` after `Create`/`Update` configurable ([#4190](#4190)). * Migrate Share Data Source to Plugin Framework ([#4161](#4161)). * Migrate Share Resource to Plugin Framework ([#4047](#4047)). * Rollout Plugin Framework ([#4134](#4134)). ### Dependency Updates * Bump Go SDK to v0.50.0 ([#4178](#4178)). ### Exporter * Allow to match resource names by regular expression ([#4177](#4177)).
…mework (#4187) ## Changes <!-- Summary of your changes that are easy to understand --> Following up for #4161 (comment), I noticed some other resources also aren't setting the user agent. Creating a PR to fix them. Also added a note in the contributing guideline. ## Tests <!-- How is this tested? Please see the checklist below and also describe any other relevant tests --> NA - [ ] `make test` run locally - [ ] relevant change in `docs/` folder - [ ] covered with integration tests in `internal/acceptance` - [ ] relevant acceptance tests are passing - [ ] using Go SDK
Changes
This PR migrates the share/shares data sources to the Plugin framework. The code was largely copied "as is" from the previous implementation of the share data source, with the necessary adaptations made for integration with the Plugin framework.
Tests
Note: current tests create shares using the SDKv2 resource, but fetch them using the new plugin framework data source. Once the resource migration will be merged, I will amend this.Edit: Now that the resource itself is merged, the acceptance tests use the plugin framework's version of the resource.make test
run locallydocs/
folderinternal/acceptance