Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

output-request-json doesn't #2569

Open
qrkourier opened this issue Dec 3, 2024 · 5 comments
Open

output-request-json doesn't #2569

qrkourier opened this issue Dec 3, 2024 · 5 comments

Comments

@qrkourier
Copy link
Member

$ ziti edge list edge-routers --output-request-json 'tags.foo = "bar"'       
╭────┬──────┬────────┬───────────────┬──────┬────────────╮
│ ID │ NAME │ ONLINE │ ALLOW TRANSIT │ COST │ ATTRIBUTES │
├────┼──────┼────────┼───────────────┼──────┼────────────┤
╰────┴──────┴────────┴───────────────┴──────┴────────────╯
results: none
@dovholuknf
Copy link
Member

doesn't state it explicitly, but it'll work just add --verbose

@qrkourier
Copy link
Member Author

Noted and confirmed. How shall we unconfuse future users on this point? My naive expectation was that --output-request-json would output the request JSON.

@emoscardini
Copy link
Contributor

You don't need the --verbose flag that's a completely different function, but the functionality of --output-request-json is a bit confusing since it doesn't return anything while doing list . Performing other functions does return output:

ziti edge create edge-router test --output-request-json
POST to https://127.0.0.1/edge/management/v1/edge-routers
{
    "appData": null,
    "cost": 0,
    "disabled": false,
    "isTunnelerEnabled": false,
    "name": "test",
    "noTraversal": false,
    "roleAttributes": null,
    "tags": {}
}
New edge router test created with id: 2apaydtbK

Also noticed that if you do a DELETE, the output actually shows POST instead of DELETE:

ziti edge delete edge-router test --output-request-json
POST to https://127.0.0.1/edge/management/v1/edge-routers/2apaydtbK
[]
delete of edge-router with id 2apaydtbK: OK

I would expect the list to show a simple GET & the endpoint it used.

@qrkourier
Copy link
Member Author

qrkourier commented Dec 3, 2024

It appears that the necessity of --verbose is inconsistent across the CLI's CRUD commands and uniformly required for the edge list command. However, a few types do not print the request JSON even when both flags are set: --output-request-json --verbose. Those types that always fail are auth-policies, cas, and ext-jwt-signers.

while read
do
        if unbuffer ~/go/bin/ziti edge list $REPLY --output-request-json |& grep -q RESTY
        then
                echo -e "INFO: $REPLY succeeded with --output-request-json"
        elif unbuffer ~/go/bin/ziti edge list $REPLY --output-request-json --verbose |& grep -q RESTY
        then
                echo -e "WARN: $REPLY succeeded with --verbose --output-request-json" >&2
        else
                echo -e "ERROR: $REPLY failed" >&2
        fi
done< <(awk -F'"' '/\.AddCommand\(new(Sub)?ListCmdForEntityType/ {print $2}' ./ziti/cmd/edge/list.go | sort -u)
WARN: api-sessions succeeded with --verbose --output-request-json
WARN: authenticators succeeded with --verbose --output-request-json
ERROR: auth-policies failed
ERROR: cas failed
WARN: configs succeeded with --verbose --output-request-json
ERROR: config-type failed
WARN: config-types succeeded with --verbose --output-request-json
WARN: edge-router-policies succeeded with --verbose --output-request-json
WARN: edge-router-role-attributes succeeded with --verbose --output-request-json
WARN: edge-routers succeeded with --verbose --output-request-json
WARN: enrollments succeeded with --verbose --output-request-json
ERROR: ext-jwt-signers failed
WARN: identities succeeded with --verbose --output-request-json
WARN: identity-role-attributes succeeded with --verbose --output-request-json
WARN: posture-check-role-attributes succeeded with --verbose --output-request-json
WARN: posture-checks succeeded with --verbose --output-request-json
WARN: posture-check-types succeeded with --verbose --output-request-json
WARN: service-edge-router-policies succeeded with --verbose --output-request-json
WARN: service-policies succeeded with --verbose --output-request-json
WARN: service-role-attributes succeeded with --verbose --output-request-json
WARN: services succeeded with --verbose --output-request-json
WARN: sessions succeeded with --verbose --output-request-json
WARN: summary succeeded with --verbose --output-request-json
WARN: terminators succeeded with --verbose --output-request-json
WARN: transit-routers succeeded with --verbose --output-request-json

@nenkoru
Copy link

nenkoru commented Dec 5, 2024

Noted and confirmed. How shall we unconfuse future users on this point? My naive expectation was that --output-request-json would output the request JSON.

My expectation as well was that it would output the request body. Found this gh issue to my surprise being very new. I guess best bet is to actually output it whether --verbose is present?

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

No branches or pull requests

4 participants