Repository navigation
bundle generate: add machinery for table-driven resource generators - #7365
Draft
janniklasrose wants to merge 2 commits into
Draft
janniklasrose wants to merge 2 commits into
janniklasrose wants to merge 2 commits into
Conversation
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>
Collaborator
Integration test reportCommit: 50ad83b
Top 3 slowest tests (at least 2 minutes):
|
This branch has not been deployed
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
Base PR for extending
databricks bundle generateto 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. Aresource[R, C]entry names the lookup flag and a typed fetch for API responseR; the command narrowsRto bundle resource typeCthrough 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--keyis given, writes<config-dir>/<key>.<type>.ymlunder the bundle root, warns when the file is not matched byinclude, and supports the hidden--bindflag like the existing generators. Command name, file extension, and messages come from the type'sResourceDescription.bundle/generate/resource.go:FromResponse[C]andConvertResourceToValue, 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:ConvertToMapValuewithout an explicitOrdernow 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 anOrderand are unaffected.cmd/bundle/generate_test.go: a parity test that fails when a group inconfig.SupportedResources()has neither a generate subcommand nor an entry ingenerateUnsupported. 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 generatecovers 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.goruns the generic path end to end against a fake spec: key derivation,--keyand--config-dir, skip fields, fetch errors, overwrite protection with--force, help text, and the required lookup flag.bundle/generate/resource_test.gocovers narrowing and field dropping.libs/dyn/yamlsaver/utils_test.goasserts the numbered locations.bundle/generateandbundle/helpacceptance tests pass unchanged.This pull request and its description were written by Isaac.