Skip to content

Consider files created by configlets in check.config - #3765

Open
ipspace wants to merge 2 commits into
devfrom
chk-config-files
Open

Consider files created by configlets in check.config#3765
ipspace wants to merge 2 commits into
devfrom
chk-config-files

Conversation

@ipspace

@ipspace ipspace commented Aug 12, 2026

Copy link
Copy Markdown
Owner
  • 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.

@ipspace
ipspace requested a lite review from Copilot August 12, 2026 09:30
@ipspace

ipspace commented Aug 12, 2026

Copy link
Copy Markdown
Owner Author

@roc-ops -- could you please check whether this resolves #3650 for you?

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.config to treat entries in topology.files as valid template candidates.
  • Moved check.config execution to the post_transform plugin 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.

Comment thread netsim/extra/check/config/__init__.py
Comment on lines 28 to 30
for cfg in list(ndata.config):
cfg_file: typing.Optional[str] = None
for cfg_candidate in candidate_files:
Comment thread netsim/extra/check/config/__init__.py Outdated
Comment on lines +13 to +17
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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_files is used only for membership checks inside nested loops; building it as a set avoids 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_transform hook, but the implementation uses post_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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

check.config false-positives and drops files-plugin inline configlets

2 participants