Skip to content

[Internal] Split resources in groups#5772

Draft
tanmay-db wants to merge 7 commits into
mainfrom
account-header-guard-test
Draft

[Internal] Split resources in groups#5772
tanmay-db wants to merge 7 commits into
mainfrom
account-header-guard-test

Conversation

@tanmay-db

Copy link
Copy Markdown
Contributor

Changes

Tests

  • make test run locally
  • relevant change in docs/ folder
  • covered with integration tests in internal/acceptance
  • using Go SDK
  • using TF Plugin Framework
  • has entry in NEXT_CHANGELOG.md file

tanmay-db and others added 7 commits May 28, 2026 20:19
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
@tanmay-db tanmay-db temporarily deployed to test-trigger-is June 1, 2026 11:55 — with GitHub Actions Inactive
@github-actions

github-actions Bot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Please ensure that the NEXT_CHANGELOG.md file is updated with any relevant changes.
If this is not necessary for your PR, please include the following in your PR description:
NO_CHANGELOG=true
and rerun the job.

@github-actions

github-actions Bot commented Jun 1, 2026

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: 5772
  • Commit SHA: 5c7d9be5eae676e8025550f73b1a8369236c854b

Checks will be approved automatically on success.

@tanmay-db tanmay-db temporarily deployed to test-trigger-is June 1, 2026 11:56 — with GitHub Actions Inactive
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.

2 participants