Skip to content

feat: add optional group field to server config - #56

Open
ice616 wants to merge 1 commit into
bvisible:mainfrom
ice616:feature/server-group-field
Open

feat: add optional group field to server config#56
ice616 wants to merge 1 commit into
bvisible:mainfrom
ice616:feature/server-group-field

Conversation

@ice616

@ice616 ice616 commented Jul 20, 2026

Copy link
Copy Markdown

Closes #55.

Summary

Adds an optional, free-form group label to server definitions:

  • .env: SSH_SERVER_<NAME>_GROUP=production
  • TOML: group = "production"

The field round-trips through ConfigLoader.exportToToml() / exportToEnv(), and ssh_list_servers now returns it alongside name/host/user/defaultDir/description.

Why

As discussed in #55: today a server's group/environment membership only exists in the separate .server-groups.json file used by ssh_group_manage / ssh_execute_group for batch execution. That's a different concern (execution strategy — parallel/sequential/rolling, with servers referenced by name) from descriptive grouping.

Having group live on the server entry itself means:

  • Exporting the config to another tool (or importing from one) carries the grouping information without needing a second file.
  • Many external SSH clients / vault-style host managers already have a native group/folder concept per host — this gives a natural 1:1 field to map to/from when converting configs.
  • ssh_list_servers can show group membership at a glance without cross-referencing .server-groups.json.

This is purely additive metadata — it does not touch .server-groups.json, ssh_group_manage, or ssh_execute_group, which keep working exactly as before. A follow-up could optionally let ssh_group_manage list derive a dynamic group from this field (similar to the existing all dynamic group), but that's out of scope here to keep this change minimal and low-risk.

Changes

  • src/config-loader.js: read group from both the TOML and .env loaders; write it back in both exporters. Omitted entirely when unset, so existing configs and generated output are unaffected.
  • src/index.js: ssh_list_servers includes group in its output (empty string when unset); description text updated to mention it.
  • tests/test-config-field-names.js: extended EXPECTED_CAMEL_FIELDS and both the .env/TOML fixtures to cover group, keeping it locked in alongside the other camelCase fields this test already guards.
  • README.md / CLAUDE.md: documented the new field in both the .env and TOML config references.
  • CHANGELOG.md: added an [Unreleased] entry.

Testing

npm test

All suites pass except the pre-existing test:lifecycle failures (SIGTERM/SIGINT handling), which are unrelated to this change and reproduce identically on main without this branch (verified via git stash).

Also manually verified with a scratch TOML/.env fixture (load → export → reload round-trip) that group survives every direction: TOML→loader, .env→loader, loader→exportToToml, loader→exportToEnv, and export→reload.

Adds a free-form `group` label to server definitions (SSH_SERVER_<NAME>_GROUP
in .env, group = "..." in TOML). It round-trips through exportToToml/exportToEnv
and is returned by ssh_list_servers, so a server's group membership travels
with the config itself when exporting to or importing from other tools —
distinct from the existing .server-groups.json / ssh_group_manage
batch-execution groups, which stay untouched.

Optional and additive: omitted from generated config when unset, no changes
to existing server definitions required.
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.

功能请求:为 ssh_servers 配置增加 group 字段

1 participant