Skip to content

feat: add whole-group export/import for worker groups and edge fleets#1

Draft
JacobPEvans-personal wants to merge 5 commits into
mainfrom
feat/groups-export-import
Draft

feat: add whole-group export/import for worker groups and edge fleets#1
JacobPEvans-personal wants to merge 5 commits into
mainfrom
feat/groups-export-import

Conversation

@JacobPEvans-personal

Copy link
Copy Markdown

This PR adds support for whole-group export/import functionality for worker groups and edge fleets in the Cribl CLI, along with unit tests and helper utilities.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds a new groups CLI command for exporting/importing an entire worker group or edge fleet configuration, backed by a new group_transfer utility module and unit tests.

Changes:

  • Introduces cribl_cli.utils.group_transfer to collect per-group resources into an export payload and apply an import payload with safety flags (routes/packs/lookups/sensitive).
  • Adds a new cribl groups export|import Click command and registers it in the main CLI.
  • Adds unit tests and updates CLAUDE.md documentation for the new feature.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
cribl_cli/utils/group_transfer.py Implements whole-group collect/export, import/apply, and directory-based payload IO.
cribl_cli/commands/groups.py Adds groups export and groups import CLI commands with deploy confirmation safeguards.
cribl_cli/cli.py Registers the new groups command group in the root CLI.
tests/unit/test_group_transfer.py Adds unit tests for resource planning, export aggregation, IO roundtrip, and import safety.
CLAUDE.md Documents the new command and its safety rules/conventions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +291 to +303
cfg = RESOURCE_CONFIGS.get(name)
if cfg is None:
report["skipped"][name] = "unknown resource type"
continue

for item in _items(value):
ref = f"{name}/{item.get('id', '?')}"
try:
outcome = _upsert_item(client, target_id, cfg, item)
report[outcome].append(ref)
except Exception as exc: # noqa: BLE001
report["failed"][ref] = str(exc)

Comment thread cribl_cli/utils/group_transfer.py
Comment thread cribl_cli/utils/group_transfer.py
Changes:

- Add fail-fast for target groups during import

- Skip STREAM_ONLY resources on Edge fleets

- Simplify logic in plan_resources and apply

- Catch specific httpx.HTTPError for resource operations
The "Using profiles" block showed 'cribl config set cloud' (positional) and 'cribl config list', but the config group only defines set (which takes -p/--profile), show, and use — no list. Corrected to 'config set -p cloud' and 'config show'.

Also wrapped two over-long lines and added a code-fence language for markdownlint; the collapsible commands section is intentional HTML and left as-is.

Assisted-by: Claude:claude-opus-4-8[1m]
write_dir() chmods the export directory to 0700 and each file to 0600, so --include-sensitive exports are not left world-readable (mirrors the ~/.criblrc 0600 protection).

read_input() raises on an ambiguous directory (no _meta.json plus multiple group subdirectories) instead of silently returning an empty payload that would make import a no-op.

Addresses Copilot review feedback on PR #1.

Assisted-by: Claude:claude-opus-4-8[1m]
Eight group-scoped resources used endpoint paths that return HTTP 404 on Cribl 4.17.1 (verified live against a real Leader). This broke both the factory CRUD commands (cribl <resource> list/get/...) and groups export/import for these types.

parsers system/parsers->lib/parsers; schemas schemas->lib/schemas; db-connections lib/db-connections->lib/database-connections; conditions lib/conditions->conditions; sds-rules lib/sds/rules->lib/sds-rules; sds-rulesets lib/sds/rulesets->lib/sds-rulesets; appscope lib/appscope->lib/appscope-configs; hmac-functions lib/hmac->lib/hmac-functions.

Updated the one mock test that hard-coded the old parsers path. The 4 resources still 404ing (protobuf-libs, scripts, functions, alert-monitors) are left unchanged pending confirmation of their correct paths.

Assisted-by: Claude:claude-opus-4-8[1m]
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.

2 participants