Migrate validate config from datadog_checks_dev to ddev#23653
Migrate validate config from datadog_checks_dev to ddev#23653
Conversation
Port the `validate config` command, the `tooling/configuration/` spec loader, and the `tooling/config_validator/` legacy YAML linter from `datadog_checks_dev` into ddev: - ddev/src/ddev/cli/validate/config.py: native command using the ddev Application/Integration model, with the same CLI surface (`[CHECK]`, `--sync/-s`, `--verbose/-v`). - ddev/src/ddev/validation/configuration/: spec loader, validator, template engine, and consumers (ExampleConsumer + ModelConsumer). The bundled templates directory moves with it. ModelConsumer .create_code_formatter() now takes an optional repo_path argument so callers can pass app.repo.path instead of relying on legacy get_root. - ddev/src/ddev/validation/config_spec/: legacy YAML linter ported one-to-one. Public surface (validate_config, SEVERITY_ERROR, SEVERITY_WARNING) unchanged. - Legacy command file, its entry in ALL_COMMANDS, and the legacy test_config.py are deleted; the bundled my_check / tokumx fixtures stay because validate models tests still consume them. - Tests rewritten as plain pytest functions in ddev/tests/cli/validate /test_config.py using fake_repo/fake_extras_repo/fake_marketplace_repo. PR 1.13 (validate models) will reuse `ddev.validation.configuration` unchanged.
|
|
|
✨ Fix all issues with BitsAI or with Cursor
|
Codecov Report❌ Patch coverage is Additional details and impacted files🚀 New features to boost your workflow:
|
- Widen validate_fields fields_dict to Mapping[str, object] (read-only key access). - Correct ModelConsumer.render() return type to Dict[str, Dict[str, Tuple[str, List[str]]]] to match runtime; tighten related helpers and local dicts. - Annotate openapi_document containers and let _build_type_data return dict | None. - Annotate spec.files_validator local dicts.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 364a36020a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if check is None or check.lower() == 'all': | ||
| selection = () | ||
| names = sorted({integration.name for integration in app.repo.integrations.iter_all(selection)}) | ||
| elif check.lower() == 'changed': | ||
| changed = sorted({integration.name for integration in app.repo.integrations.iter_changed_code()}) | ||
| valid = {integration.name for integration in app.repo.integrations.iter_all(())} |
There was a problem hiding this comment.
Pass an explicit all selection here
When check is omitted or set to all on a dirty checkout/PR, this uses iter_all(()), but IntegrationRegistry.__finalize_selection treats an empty selection as “changed root entries” when any files have changed. As a result ddev validate config all silently validates only changed integrations instead of all valid checks; the same empty-selection lookup on line 156 also prevents the datadog_checks_dev/datadog_checks_base changed case from expanding to the full set. Use the registry's explicit all selection (or another unfiltered path) for these all-check lookups.
Useful? React with 👍 / 👎.
Validation Report
Run Passed validations (19)
|
What does this PR do?
Migrates the
validate configcommand fromdatadog_checks_dev/.../tooling/commands/validate/config.pytoddev/src/ddev/cli/validate/config.py, rewriting the implementation to use ddev'sApplicationoutput style andRepository/Integrationdata model.As part of this migration, two supporting modules ship natively in ddev for the first time. They are also consumed by PR 1.13 (
validate models), which is unblocked by this PR:ddev/src/ddev/validation/configuration/— config-spec loader, validator, template engine, and consumers (ExampleConsumer,ModelConsumer). The bundledtemplates/tree moves with it.ModelConsumer.create_code_formatter()now takes an optionalrepo_pathargument so callers can passapp.repo.pathinstead of calling legacytooling.constants.get_root(). No other public-surface changes.ddev/src/ddev/validation/config_spec/— the legacy YAML linter (validate_config,SEVERITY_ERROR,SEVERITY_WARNING,ValidatorError). Internals (config_block.py,utils.py) unchanged.The legacy command file and its
ALL_COMMANDSentry are deleted in this PR. The legacy test fixtures underdatadog_checks_dev/tests/tooling/commands/validate/data/are kept becausevalidate models' legacy tests still consume them; they will be removed when that command migrates in PR 1.13.Helper gap notes
tooling.commands.console.annotate_error(GitHub Actions annotations): ddev has no equivalent. Error messages still flow throughapp.display_error; GH annotations are dropped. (Tracked separately: anapp.annotate_*primitive will be added in a follow-up infrastructure PR; this command will be retrofitted then.)tooling.testing.process_checks_option: replaced with_iter_target_checks, which usesapp.repo.integrations.iter_all(...)/iter_changed_code()and preserves thedatadog_checks_dev/datadog_checks_basefallback semantics from legacy.tooling.utils.get_data_directory/get_version_string/get_config_files: replaced with small private helpers in the migrated file.get_version_stringreads__about__.pydirectly via theIntegration.package_directoryaccessor.tooling.constants.get_root→app.repo.path.tooling.utils.complete_valid_checksautocomplete is dropped (ddev's native validate commands do not use shell completion for the[CHECK]argument).Test plan
ddev validate config --helpoutput unchanged from masterddev validate config postgresproduces identical output and exit code to masterddev validate config allproduces identical output to master (539/539 valid)ddev --no-interactive test ddevpasses the newtest_configsuite (4 happy + error path tests covering core/extras/marketplace and sync flow)ddev --no-interactive test datadog_checks_devpasses (428/428)Motivation
Part of the
datadog_checks_dev→ddevCLI migration wave (PR 1.4). Every CLI command currently registered indatadog_checks_dev's legacy tooling tree is being moved into ddev as native code, with the legacytooling/directory deleted at the end of the multi-phase migration. This PR is the heaviest in the validate wave because it ships not only the migrated command but also the two supporting modules (validation/configuration/andvalidation/config_spec/) that PR 1.13 (validate models) will reuse. Landing this PR is the gate for the rest of the validate wave.Review checklist (to be filled by reviewers)
qa/skip-qalabel if the PR doesn't need to be tested during QA.backport/<branch-name>label to the PR and it will automatically open a backport PR once this one is merged