[Internal] Split resources in groups#5772
Draft
tanmay-db wants to merge 7 commits into
Draft
Conversation
Move X-Databricks-Workspace-Id injection out of common.DatabricksClient's
helpers and into each workspace-level resource. The previous central
approach fired on every raw-HTTP call gated only on Config.WorkspaceID;
this is fragile for account-only and dual resources because the same
client config can carry a WorkspaceID even when the call targets an
account endpoint.
- Get/Post/Patch/Delete/Put now take variadic visitors; workspace-only
callsites pass c.AddWorkspaceIdHeader explicitly (~137 callsites across
repos, pools, sharing, access, catalog, workspace, clusters, storage,
aws, commands, tokens, sql, jobs-legacy, exporter).
- Scim helper injects the header conditionally based on apiLevel so
dual SCIM (users/groups/service_principals) sends it at workspace
level and skips it at account level.
- mws/* (account-only, paths under /accounts/{aid}/...) untouched.
Co-authored-by: Isaac
databricks_repo.path requires /Repos/<directory>/<repo> (3 components after the leading slash) per validatePath in repos/resource_repo.go. The test fixture used /Repos/tf-acc-<rand> (2 components), causing ValidateResourceConfig to fail before any API call: Error: should have 3 components (/Repos/<directory>/<repo>), got 2 Failure surfaced in eng-dev-ecosystem run 26627275255 on the *-acct-* matrix legs (TestMwsAccUnifiedHostCreateRepo, TestMwsAccAccountHostCreateRepo). Co-authored-by: Isaac
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.
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.
Drives every resource in AccountResources (the group introduced by the SDKv2 api-level split) through CRUD against a header-capturing server with a workspace id set in config, and asserts no request ever carries X-Databricks-Workspace-Id. Catches a future edit that wires common.AddWorkspaceIdHeader onto a callsite an account resource reaches, and exercises the /accounts/ suppression guard. Includes a positive control proving the capture client can see the header. Co-authored-by: Isaac
Contributor
|
Please ensure that the NEXT_CHANGELOG.md file is updated with any relevant changes. |
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.
Changes
Tests
make testrun locallydocs/folderinternal/acceptanceNEXT_CHANGELOG.mdfile