resolvectl: add JSON output support for "resolvectl query"

It's easy to add. Let's do so.

This only covers record lookups, i.e. with the --type= switch.

The higher level lookups are not covered, I opted instead to print a
message there to use --type= instead.

I am a bit reluctant to defining a new JSON format for the high-level
lookups, hence I figured for now a helpful error is good enough, that
points people to the right use.

Fixes: #29755
This commit is contained in:
Lennart Poettering
2024-01-31 16:13:16 +01:00
parent 1d556e9e2a
commit 3557f1a62a
3 changed files with 38 additions and 10 deletions
+3
View File
@@ -821,6 +821,9 @@ run resolvectl reset-statistics --json=pretty
run resolvectl reset-statistics --json=short
test "$(resolvectl --json=short query -t AAAA localhost)" == '{"key":{"class":1,"type":28,"name":"localhost"},"address":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1]}'
test "$(resolvectl --json=short query -t A localhost)" == '{"key":{"class":1,"type":1,"name":"localhost"},"address":[127,0,0,1]}'
# Check if resolved exits cleanly.
restart_resolved