Add all-user domain and database listing commands - #5657
thomas-berrio wants to merge 3 commits into
Conversation
jaapmarcus
left a comment
There was a problem hiding this comment.
When running even on a test server with 3 users it runs all quite.
When running it on a server with 100 users wil will even run slower...
0.65 sec instead 0.98 sec when I only do 1 user.
cat /usr/local/hestia/data/user/*/web.conf and then phrase it probally a lot faster
Als there is not need to include the api presets for it on default
There was a problem hiding this comment.
There is not need of offering those 4 functions separately in api keys as api keys. If you need them you should probally want more wider api keys or have the knowledge to create them self
| fi | ||
|
|
||
| # Add the list-all-user-objects API key permission. | ||
| cp "$HESTIA/install/common/api/list-all-user-objects" "$HESTIA/data/api/list-all-user-objects" |
There was a problem hiding this comment.
No need to include them in the update script
|
|
||
| printf '{"USER":"%s","OBJECTS":%s}\n' "$user" "$objects" | ||
| done <<< "$users" | ||
| } | jq --indent 4 -s 'map(.USER as $user | .OBJECTS | with_entries(.value = ({ USER: $user } + .value))) | add // {}' |
There was a problem hiding this comment.
I don't know why it list it for every user
But cat /usr/local/hestia/user/*/{any}.conf and parse it once is probably faster.
Read user inventories in one awk pass, require user.conf for inventory owners, and retain legacy output fields with intentional mail CSV and field-isolation differences. Add standalone fixtures and installed-command equivalence coverage.
ea8771e to
c891996
Compare
|
Thanks @jaapmarcus for the review. I’ve addressed your feedback:
Two output differences are intentional and documented: missing fields no longer inherit values from previous records, and mail CSV omits the legacy blank separator lines. Local validation passes: 21 fixture tests, ShellCheck at the CI error threshold, and repository-wide Prettier checks. The full Hestia integration suite still needs CI validation. Could you take another look and approve the workflows if approval is still required? Thanks! |
Use the configured WEBMAIL_ALIAS only when a mail record omits the key. Preserve explicit empty and custom aliases, and test the fallback across records, users and output formats.
Summary
Add server-wide listing commands intended for CLI and HTTP API consumers managing large HestiaCP installations:
v-list-all-web-domains [FORMAT]v-list-all-mail-domains [FORMAT]v-list-all-dns-domains [FORMAT]v-list-all-databases [FORMAT]Each command supports the existing
plain,csv,shell, andjsonformats and adds the owningUSERto every returned object or row.Motivation
The current list commands are scoped to a single user. API clients that need a server-wide inventory must first list the users and then perform one request per user and object type.
These commands provide that inventory through one CLI or HTTP API request, which is especially useful when managing a large number of users and sites.
Implementation
v-list-users listand the existing user-scopedv-list-*commands through$BIN.func/list.shhelper.list-all-user-objectsAPI permission covering the four commands.This intentionally performs one existing list command per user. It avoids duplicating the parsing of Hestia configuration files and keeps the new output aligned with the existing commands.
Mail, DNS, and database listings are included because they use the same aggregation and authorization model as web domains, with no changes to their existing commands.
Tests
Added coverage for:
Local syntax, diff, error-propagation, and security mock checks pass. The complete HestiaCP test suite and repository formatting checks will also run through CI.
Closes #4854