Consider files created by configlets in check.config - #3765
Conversation
53bf359 to
ec58c42
Compare
There was a problem hiding this comment.
Pull request overview
This PR updates the check.config extra plugin to account for config template files that will be created by the files plugin (configlets), and moves the validation to the post_transform hook so it runs before provider post_transform logic (notably for clab).
Changes:
- Added coverage test topology and expected output for a configlet-generated template file.
- Updated
check.configto treat entries intopology.filesas valid template candidates. - Moved
check.configexecution to thepost_transformplugin hook and added_execute_after = ['files']ordering.
Reviewed changes
Copilot reviewed 1 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| tests/coverage/input/check-config-files.yml | New coverage input exercising files + check.config with a configlet. |
| tests/coverage/expected/check-config-files.yml | Expected transformed topology showing files: content and resulting node config artifacts. |
| netsim/extra/check/config/init.py | Moves logic to post_transform and checks configlet-created files via topology.files. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| for cfg in list(ndata.config): | ||
| cfg_file: typing.Optional[str] = None | ||
| for cfg_candidate in candidate_files: |
| missing = data.get_empty_box() | ||
| if 'files' in topology: | ||
| extra_files = [ x.path for x in topology.files if isinstance(x,Box) and 'path' in x ] | ||
| else: | ||
| extra_files = [] |
* The 'check.config' main loop checks files that will be created by the 'files' plugin (the 'files' list) when trying to figure out if it's safe to use a custom configuration template. * The 'check.config' logic was moved to the 'post_quirks' plugin hook to be executed before provider post_transform hook which creates all sorts of hard-to-deal-with data (in clab case). This should be late enough in the process to have the final 'config' list, and it's also the very last plugin hook before clab provider does its stuff.
ec58c42 to
5dc2c12
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 3 changed files in this pull request and generated no new comments.
Suppressed comments (3)
netsim/extra/check/config/init.py:7
- Remove unused import
a_devices; it is not referenced in this module and will fail linting (ruff F401).
from netsim import data
from netsim.augment import devices as a_devices
from netsim.utils import files as _files
netsim/extra/check/config/init.py:17
extra_filesis used only for membership checks inside nested loops; building it as asetavoids O(n) list scans per candidate path when many files are present.
if 'files' in topology:
extra_files = [ x.path for x in topology.files if isinstance(x,Box) and 'path' in x ]
else:
extra_files = []
netsim/extra/check/config/init.py:12
- PR description says the check.config logic was moved to the
post_transformhook, but the implementation usespost_quirks; consider aligning the description (or hook name) to avoid confusion about execution order.
def post_quirks(topology: Box) -> None:
* Use a set of extra files, not a list * Remove unnecessary import
Uh oh!
There was an error while loading. Please reload this page.