Skip to content

bundle generate: add machinery for table-driven resource generators - #7365

Draft
janniklasrose wants to merge 2 commits into
mainfrom
janniklasrose/bundle-generate-machinery
Draft

janniklasrose wants to merge 2 commits into
mainfrom
janniklasrose/bundle-generate-machinery

Conversation

@janniklasrose

Copy link
Copy Markdown
Member

Changes

Base PR for extending databricks bundle generate to every bundle resource type. It adds the shared machinery only; one stacked PR per resource family follows and fills in the table.

  • cmd/bundle/generate/generic.go: a table-driven generate subcommand for resource types that are read with a single API call and have no files to download. A resource[R, C] entry names the lookup flag and a typed fetch for API response R; the command narrows R to bundle resource type C through a JSON round-trip, drops CLI-managed fields (id, modified_status, url) plus any per-type skip fields, derives the key from the resource name unless --key is given, writes <config-dir>/<key>.<type>.yml under the bundle root, warns when the file is not matched by include, and supports the hidden --bind flag like the existing generators. Command name, file extension, and messages come from the type's ResourceDescription.
  • bundle/generate/resource.go: FromResponse[C] and ConvertResourceToValue, the narrowing and serialization steps, kept separate from the command so family PRs can use them for responses that need unwrapping first.
  • libs/dyn/yamlsaver: ConvertToMapValue without an explicit Order now numbers entries so the alphabetical sort survives encoding. Previously the encoder fell back to Go map iteration order, which would have made generated YAML non-deterministic. All existing callers pass an Order and are unaffected.
  • cmd/bundle/generate_test.go: a parity test that fails when a group in config.SupportedResources() has neither a generate subcommand nor an entry in generateUnsupported. That list is the to-do list for the follow-up PRs.

The spec table is empty in this PR, so there is no user-visible change and no changelog fragment.

Why

bundle generate covers six resource types by hand-written commands. The remaining thirty-odd types share the same shape (fetch, narrow, save), so a table keeps each addition to a few lines and lets the family PRs be reviewed on the resource specifics rather than on command plumbing.

Tests

  • cmd/bundle/generate/generic_test.go runs the generic path end to end against a fake spec: key derivation, --key and --config-dir, skip fields, fetch errors, overwrite protection with --force, help text, and the required lookup flag.
  • bundle/generate/resource_test.go covers narrowing and field dropping.
  • libs/dyn/yamlsaver/utils_test.go asserts the numbered locations.
  • Existing bundle/generate and bundle/help acceptance tests pass unchanged.

This pull request and its description were written by Isaac.

janniklasrose and others added 2 commits November 4, 2026 22:27
ConvertToMapValue sorts keys alphabetically, but without an Order the entries
were stored with zero-valued locations and the encoder, which orders by
Location.Line, fell back to Go map iteration order. Number the entries so the
sorted order survives. Existing callers all pass an Order and are unaffected.

Co-authored-by: Isaac <no-reply@databricks.com>
Adds a table-driven generate subcommand for resource types that are read with
one API call and have no files to download. A resource[R, C] entry names the
lookup flag and a typed fetch; the command narrows the response to the bundle
resource type via a JSON round-trip, drops CLI-managed and skipped fields,
derives the key from the resource name, writes <config-dir>/<key>.<type>.yml
under the bundle root, warns if the file is not included, and supports the
hidden --bind flag like the existing generators.

The table starts empty; resource families are added in follow-up PRs. A
parity test in cmd/bundle fails when a group from config.SupportedResources
is neither generated nor listed as unsupported, so new resource types get an
explicit decision.

Co-authored-by: Isaac <no-reply@databricks.com>
@github-actions github-actions Bot added the DABs DABs related issues label Nov 4, 2026
@eng-dev-ecosystem-bot

Copy link
Copy Markdown
Collaborator

Integration test report

Commit: 50ad83b

Run: 41925740100

Env ✅​pass 🙈​skip Time
✅​ aws linux-2core-8gb 271 15 4:04
✅​ aws-windows-latest-4core-16gb 273 13 3:29
✅​ azure linux-2core-8gb 270 15 4:11
✅​ azure-windows-latest-4core-16gb 272 13 3:38
✅​ gcp linux-2core-8gb 271 15 4:15
✅​ gcp-windows-latest-4core-16gb 273 13 3:43
Top 3 slowest tests (at least 2 minutes):
duration env testname
3:37 gcp-windows-latest-4core-16gb TestAccept
3:32 azure-windows-latest-4core-16gb TestAccept
3:24 aws-windows-latest-4core-16gb TestAccept

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

DABs DABs related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants