Repository navigation
Document the files a new resource type needs and guard shared code against naming resource types - #8043
Draft
janniklasrose wants to merge 11 commits into
Conversation
The steps to add a resource type were spread over several READMEs that repeated each other and named files that do not exist. bundle/config/resources/README.md now lists every file a new type needs, in the order they are written, each with the test that fails while it is missing, plus the per-type registrations for behaviour that needs the whole bundle. The other documents keep what is specific to their package and link to that list. Co-authored-by: Isaac <no-reply@databricks.com>
Logic about one resource type belongs in that type's files, but nothing stopped a new type from being wired into a shared list by hand. TestSharedCodeNamesNoNewResourceTypes parses the hand-written Go files under bundle/ and cmd/bundle/ that are not named after a resource key, and records which resource types each one names: a string that is a resource key, a field of config.Resources, or a config type. The record is a sorted text file, so naming a new type in shared code shows up as a one-line diff, and the test fails when a file names a type the record does not list for it or stops naming one it does. The Terraform state mappings and generated files are excluded. Co-authored-by: Isaac <no-reply@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
The target mode tests take their examples from one file per resource type, and the state load tests cover every type by construction, so the list of files a new type needs names the per-type file instead of two shared test files. Co-authored-by: Isaac <no-reply@databricks.com>
The telemetry rule and the resources_metadata comment cited a test that no longer exists, and the rule said a new type needs no telemetry change at all, which contradicts the resource types README: a type with lifecycle.started declares its telemetry key, and deploy bool values register per type. Name the existing test and link to the README instead of repeating it. Co-authored-by: Isaac <no-reply@databricks.com>
TestAppropriateResourcesAreRenamed only checks types whose target mode examples are registered, so it says nothing about a new type until step 13. TestCreateRecoveryCoverage fails unless the adapter recovers from a failed create or opts out; the step did not say so. Co-authored-by: Isaac <no-reply@databricks.com>
AGENTS.md named a bundle/mutator/ directory that does not exist; the Mutator interface lives in bundle/mutator.go. The Python support fixtures also hold a generated out.test.toml, so they are seven files, not six. Co-authored-by: Isaac <no-reply@databricks.com>
Shared code that held config.Resources in a variable (r := b.Config.Resources; r.Jobs) could name a resource type without the guard test noticing. Treat a variable that the same function sets to a Resources value, or a pointer to one, like that value, and pin the rule with snippet tests. The record is unchanged. The doc comment now names the record's known false positive so it is not removed by mistake. Co-authored-by: Isaac <no-reply@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
The fake server registers permission object types from the file of each API, and the per-type files under bundle/deploy are named after the resource key. The list of files a new type needs says both, names the list of types the deployment history service accepts, and the record of shared code that names resource types drops the three renamed files. Co-authored-by: Isaac <no-reply@databricks.com>
Contributor
Regression test report ✅Commit: Selected 20 changed tests (limit=20, 99 not selected) 128 tests: regression=2 unreleased=0 coverage=126 failing=0
TestAccept/bundle/resources/grants/model_services/DMS=: branch ✅ | main (3f3ebfd) ❌ | latest (v1.28.0) ❌main (3f3ebfd): latest (v1.28.0): TestAccept/bundle/resources/grants/model_services/DMS=true: branch ✅ | main (3f3ebfd) ❌ | latest (v1.28.0) ❌main (3f3ebfd): latest (v1.28.0): |
The test that guards schema annotations passes for a placeholder that is committed in the generated file, so the list of files a new type needs tells the reader to check for one. Co-authored-by: Isaac <no-reply@databricks.com>
Collaborator
✅ Integration test reportCommit: fda6a2c
Top 30 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
bundle/config/resources/README.mdgets one section, "Adding a resource type": every file a new type needs, in the order you would write them, each with what it declares or registers and the test that fails while it is missing. A second table lists the registrations for behaviour that needs the whole bundle.AGENTS.md, and the rules for generated files and telemetry link to that section instead of repeating it. Statements that the code contradicts are corrected: a test that does not exist,resources.yml, the names of invariant configs, a directory that does not exist.TestSharedCodeNamesNoNewResourceTypes. It parses the hand-written, non-test Go files underbundle/andcmd/bundle/that are not named after a resource key, and records which resource types each one names inbundle/config/resources/testdata/shared_code_resource_types.txt. It fails when a file names a type the record does not list for it, and when a listed type is no longer named.-updateregenerates the record.This builds on #8042, which is based on the combined branch of the per-resource changes.
Why
Logic about one resource type lives in files named after its key. Nothing kept a new type from being wired into a shared list by hand, and the steps to add a type were spread over several documents.
The record turns each new mention of a resource type in shared code into a one-line diff in review. It holds 15 files today: the shared code that still names a resource type, such as validators that keep per-type branches, the Python wheel trampoline and the apps validation.
Measured on the combined branch by taking
feature_specsout and adding it again: the change that originally added the type edited 20 shared hand-written files besidesbundle/config/resources.go. The measurement found two left, both test fixtures, and #8035 and #8036 removed the need for those. A new type now has to edit one shared hand-written file,bundle/config/resources.go.The guard is syntactic. It does not see a branch on an SDK type, a
Resourcesvalue passed as a parameter, a singular name, or code outsidebundle/andcmd/bundle/.Tests
Resources.This pull request and its description were written by Isaac.