[Internal] Group SDKv2 resources and data sources by API level#5752
Draft
renaudhartert-db wants to merge 2 commits into
Draft
[Internal] Group SDKv2 resources and data sources by API level#5752renaudhartert-db wants to merge 2 commits into
renaudhartert-db wants to merge 2 commits into
Conversation
Move the SDKv2 resource and data source registration out of sdkv2.go into a new resources.go, split into Workspace*, Account*, and Dual* maps. Add a registration-consistency test that asserts the dual invariant from the schema (every entry in Dual* has an "api" attribute; every entry in Workspace* / Account* does not) and a no-overlap test that catches accidental double-registration across the resource maps and across the data source maps. The workspace-vs-account split is an organizational distinction with no runtime effect today; Resources() and DataSources() flatten all three maps. The split makes intent visible at the registration site and gives a clear home for future account-level additions. The TODO in common/resource.go calls out the proper next step: a resource-level Level annotation; that is out of scope here.
Contributor
|
Please ensure that the NEXT_CHANGELOG.md file is updated with any relevant changes. |
Extract the duplicate-key check into a testNoDuplicateKeys helper and a count helper. TestNoDuplicateKeys now invokes the helper twice, once for the data source maps and once for the resource maps, keeping the two namespaces separate.
Contributor
|
If integration tests don't run automatically, an authorized user can run them manually by following the instructions below: Trigger: Inputs:
Checks will be approved automatically on success. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Moves the SDKv2 resource and data source registration out of
sdkv2.gointo a newresources.go, split intoWorkspace*,Account*, andDual*maps.sdkv2.gonow callsDataSources()/Resources(), which flatten the three maps viamerge.Adds two registration-consistency tests in
resources_test.go:TestApiField_RegistrationConsistencyasserts the dual invariant from the schema; every entry inDual*must have anapiattribute, and every entry inWorkspace*/Account*must not. The dual case is mechanically detectable becausecommon.AddApiFieldis the single source of theapischema attribute.TestNoOverlapasserts that a Terraform name appears in at most one resource map and at most one data source map. Resource and data source namespaces are checked separately (adatabricks_tableresource anddatabricks_tabledata source legitimately coexist).The workspace-vs-account split is an organizational distinction with no runtime effect today; the merged map is what the provider uses. The split makes intent visible at the registration site and gives a clear home for future account-level additions. There is no mechanical schema signal that distinguishes workspace from account; the TODO in
common/resource.golines 117-122 calls out the proper next step (a resource-levelLevelannotation), which is out of scope here.Test plan
go build ./...cleanmake fmt lint wscleango test ./internal/providers/sdkv2/...passes, including the two new tests