You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Exporter] Initial support for resources implemented with plugin framework (#5176)
## Changes
<!-- Summary of your changes that are easy to understand -->
This PR adds support for Terraform Plugin Framework-based resources to
the exporter, which previously only supported legacy SDKv2 resources.
The implementation uses a hybrid approach that maximizes code reuse
(~70%) while respecting the framework-specific HCL syntax differences.
Resolves: #4050
### Key Changes
**Abstraction Layer**: Introduced `ResourceDataWrapper`,
`SchemaWrapper`, and `FieldSchema` interfaces in
`exporter/abstractions.go` to provide a unified way to interact with
both SDKv2's `schema.ResourceData` and Plugin Framework's `tfsdk.State`.
These abstractions enable the exporter to read resource data, access
schemas, and query field types consistently across both frameworks.
**Unified Code Generation**: Implemented a hybrid HCL generation
approach in `exporter/codegen.go` with a single entry point
`unifiedDataToHcl()`. The implementation extracts ~70% of common logic
into shared helper functions (`extractFieldsForGeneration()`,
`generateDependsOnAttribute()`), while maintaining framework-specific
functions (`generateSdkv2Field()`, `generatePluginFrameworkField()`) for
handling the key difference: SDKv2 generates nested structures as blocks
(`evaluation { ... }`), while Plugin Framework uses attribute syntax
(`evaluation = { ... }`).
**New Unified Callbacks**: Added `ShouldOmitFieldUnified` and
`ShouldGenerateFieldUnified` to the `importable` struct, which work with
both frameworks through the abstraction layers. Legacy callbacks
(`ShouldOmitField`, `ShouldGenerateField`) remain for backward
compatibility, and resources can be gradually migrated to the unified
versions. The default omission logic was also corrected to properly skip
all computed fields, matching the original SDKv2 behavior.
**Plugin Framework Resource Support**: Implemented full support for
`databricks_alert_v2` as the first Plugin Framework resource. The
implementation includes proper state initialization, conversion helpers
(`convertPluginFrameworkToGoSdk`), dependency emission, and correct
handling of nested attributes. Added comprehensive test fixtures
(`emptyAlertsV2`) to ensure compatibility with existing test suites.
### Testing & Documentation
All existing tests pass, including critical code generation tests
(`TestNotebookGeneration`, `TestDirectoryGeneration`,
`TestImportingSqlObjects`). Updated `AGENTS.md` with the new unified
code generation architecture and added the exporter architecture
section. Updated `docs/guides/experimental-exporter.md` support matrix
to reflect support for both `databricks_alert` and `databricks_alert_v2`
resources.
### Benefits
This implementation maintains 100% backward compatibility with existing
SDKv2 resources while enabling easy addition of new Plugin Framework
resources. The unified approach reduces technical debt, provides a
single source of truth for business logic, and makes future maintenance
significantly easier as the provider transitions to Plugin Framework.
## Tests
<!--
How is this tested? Please see the checklist below and also describe any
other relevant tests
-->
- [x] `make test` run locally
- [x] relevant change in `docs/` folder
- [ ] covered with integration tests in `internal/acceptance`
- [ ] using Go SDK
- [x] using TF Plugin Framework
- [x] has entry in `NEXT_CHANGELOG.md` file
Copy file name to clipboardExpand all lines: docs/guides/experimental-exporter.md
+4-1Lines changed: 4 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -154,7 +154,7 @@ Services could be specified in combination with predefined aliases (`all` - for
154
154
-> Please note that for services not marked with **listing**, we'll export resources only if they are referenced from other resources.
155
155
156
156
*`access` - **listing**[databricks_permissions](../resources/permissions.md), [databricks_instance_profile](../resources/instance_profile.md), [databricks_ip_access_list](../resources/ip_access_list.md), and [databricks_access_control_rule_set](../resources/access_control_rule_set.md). *Please note that for `databricks_permissions` we list only `authorization = "tokens"`, the permissions for other objects (notebooks, ...) will be emitted when corresponding objects are processed!*
0 commit comments