Skip to content

Add provider level workspace id support for migrated resources#5582

Open
Divyansh-db wants to merge 4 commits intodivyansh-vijayvergia_data/dwsid-sdkv2-go-sdkfrom
divyansh-vijayvergia_data/wsid-pf-migrated
Open

Add provider level workspace id support for migrated resources#5582
Divyansh-db wants to merge 4 commits intodivyansh-vijayvergia_data/dwsid-sdkv2-go-sdkfrom
divyansh-vijayvergia_data/wsid-pf-migrated

Conversation

@Divyansh-db
Copy link
Copy Markdown
Contributor

@Divyansh-db Divyansh-db commented Apr 13, 2026

Summary

  • Migrate databricks_share, databricks_library, and databricks_quality_monitor from Namespace_SdkV2 (types.List) to Namespace (types.Object) for provider_config, unifying them with the pattern already used by databricks_app
  • Make ProviderConfig.workspace_id Optional+Computed centrally, eliminating per-resource overrides (removes the manual override from resource_app.go)
  • Skip SingleNestedAttributeBuilder in convertAttributesToBlocks() so that ConfigureAsSdkV2Compatible() no longer panics when the schema contains types.Object fields like provider_config
  • Add WorkspaceDriftDetection and ValidateWorkspaceID to all three resources' ModifyPlan, and PopulateProviderConfigInState to their Create/Read methods
  • Remove common.Namespace from the SDKv2 implementations of migrated resources (share, library, quality_monitor) to enable seamless bidirectional SDKv2↔PF migration at schema version 0 without a state upgrader
  • Add 22 acceptance tests for databricks_share covering all workspace ID routing scenarios (override precedence, drift detection, ForceNew on workspace change, error cases)

Details

Why types.Object instead of types.List?

provider_config with types.List + Namespace_SdkV2 was the original SDKv2-compatible approach, but it caused a perpetual diff: Terraform Core's proposedNewBlock logic for ListNestedBlock does not preserve prior state when config is absent, forcing a diff on every plan. types.Object + SingleNestedAttribute with Optional+Computed avoids this because TC's optionalValueNotComputable preserves the attribute from prior state when all children are Computed.

Why skip SingleNestedAttributeBuilder in convertAttributesToBlocks?

SingleNestedAttributeBuilder implements Blockable but its ToBlock() panics — types.Object has no SDKv2 block equivalent. The skip ensures SDKv2-migrated resources that embed Namespace (types.Object) can call ConfigureAsSdkV2Compatible() without crashing. The ConfigureProviderConfig() helper then applies the required Optional+Computed flags and ProviderConfigPlanModifier after the SdkV2-compat conversion.

Why no state upgrader for bidirectional migration?

The migrated resources never had provider_config in their original SDKv2 implementations — common.Namespace support is added per-resource, and these resources were migrated to PF before it existed. By keeping both SDKv2 and PF at schema version 0 (the Go default), the framework's passthrough path (IgnoreUndefinedAttributes: true) handles both directions transparently:

  • SDKv2→PF: Missing provider_config in state → null (Optional+Computed, valid)
  • PF→SDKv2: Extra provider_config in state → silently ignored
  • SDKv2 timeouts (e.g. quality_monitor): Also silently ignored by the passthrough

This allows users to freely switch between SDKv2 (USE_SDK_V2_RESOURCES) and PF without state manipulation.

Test plan

  • Unit tests pass
  • 22 share workspace_id acceptance tests pass (6 workspace-level ucws + 16 account-level ucacct), covering: default routing, override precedence, drift detection, ForceNew on workspace change, remove/add override, error cases
  • 6 bidirectional migration tests pass: TestUcAccShareMigrationFromSDKv2, TestUcAccShareMigrationFromPluginFramework, TestUcAccUpdateQualityMonitorTransitionFromSdkV2, TestUcAccUpdateQualityMonitorTransitionFromPluginFw, TestAccLibraryUpdateTransitionFromSdkV2, TestUcAccShareVolume
  • 14 ProviderConfig validation tests pass (Invalid, Mismatched, EmptyID, NotProvided, Match, Recreate, Remove for share; Mismatched for quality_monitor and library; data source tests)
  • 1 ProviderConfig test skipped (TestAccShare_ProviderConfig_Multiple) — HCL-level "Attribute redefined" error breaks the test framework's post-match state retrieval; this is a Terraform testing framework limitation, not a provider bug
  • Existing app acceptance tests unaffected
  • make diff-schema confirms no breaking schema changes for existing users (provider_config was already Optional for app; share/library/quality_monitor move from ListNestedBlock to SingleNestedAttribute — validated via acceptance tests)

NO_CHANGELOG=true

@Divyansh-db Divyansh-db requested review from a team as code owners April 13, 2026 13:36
@Divyansh-db Divyansh-db requested review from renaudhartert-db and removed request for a team April 13, 2026 13:36
@Divyansh-db Divyansh-db requested review from tanmay-db and removed request for a team and renaudhartert-db April 13, 2026 13:54
…d resources to enable bi directional migration
@github-actions
Copy link
Copy Markdown
Contributor

If integration tests don't run automatically, an authorized user can run them manually by following the instructions below:

Trigger:
go/deco-tests-run/terraform

Inputs:

  • PR number: 5582
  • Commit SHA: 616a4db9890423977ee2d7bdc8d63a81341e6e5d

Checks will be approved automatically on success.

@Divyansh-db Divyansh-db changed the base branch from main to divyansh-vijayvergia_data/dwsid-sdkv2-go-sdk April 16, 2026 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant