Skip to content

iam: include policy in role show output - #903

Merged
natalie-o-perret merged 4 commits into
masterfrom
fix/iam-role-show-policy
Sep 3, 2026
Merged

iam: include policy in role show output#903
natalie-o-perret merged 4 commits into
masterfrom
fix/iam-role-show-policy

Conversation

@natalie-o-perret

@natalie-o-perret natalie-o-perret commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Description

Show an IAM role policy alongside the normal role details. The policy is rendered as a separate table with a Policy: heading. Keep --policy as the existing policy-only output for scripts.

JSON output includes the policy under policy.

Checklist

(For exoscale contributors)

  • Changelog updated (under Unreleased block, and add the Pull Request #number for each bit you add to the CHANGELOG.md)
  • Testing

Testing

Live before/after check using a temporary role with a denied service and three policy rules. The role was deleted after capturing the output.

Before, using the installed binary:

$ exo iam role show cli-pr-903-policy-output-test
| ID          | <role-id>                            |
| Name        | cli-pr-903-policy-output-test        |
| Description | Temporary CLI PR 903 output test     |
| Editable    | true                                 |
| Labels      | purpose:cli-pr-903                   |
| Permissions | n/a                                  |

After, using the patched binary:

$ ./bin/exo iam role show cli-pr-903-policy-output-test
| ID          | <role-id>                            |
| Name        | cli-pr-903-policy-output-test        |
| Description | Temporary CLI PR 903 output test     |
| Editable    | true                                 |
| Labels      | purpose:cli-pr-903                   |
| Permissions | n/a                                  |

Policy:
| SERVICE | TYPE (DEFAULT STRATEGY "ALLOW") | RULE ACTION |                     RULE EXPRESSION                     |
|---------|---------------------------------|-------------|---------------------------------------------------------|
| sos     | rules                           | allow       | operation in ['list-sos-buckets-usage', 'list-buckets'] |
|         |                                 | deny        | !(resources.bucket in ['my-bucket', 'my-other-bucket']) |
|         |                                 | deny        | operation in ['list-objects', 'get-object']             |
| cdn     | deny                            |             |                                                         |

A live read-only check against the existing DBaaS role confirms the final blank-line and heading layout.

JSON output contains the complete policy under policy. --policy continues to print only the policy table.

A focused fake API test covers the reported deny-by-default policy with compute and networking allowed. go test ./cmd/iam passes.

The full make test-verbose suite passes. make build succeeds. golangci-lint run --timeout 4m reports 0 issues.


Note

AI assistance: PR description, test scaffolding.

@natalie-o-perret

Copy link
Copy Markdown
Contributor Author

[SC-196302]

@kobajagi

kobajagi commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Can you add example of the output table with full featured policy?

@natalie-o-perret

Copy link
Copy Markdown
Contributor Author

Can you add example of the output table with full featured policy?

Updated the PR description accordingly with output from a live full-featured policy, including allow and deny rules with expressions.

@kobajagi

kobajagi commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Thanks @natalie-o-perret . IMO it feels cluttered, rule expression can also be very long which will extend policy table even more. Probably why policy was factored out in the first place.

Comment thread cmd/iam/iam_role_show.go
@natalie-o-perret natalie-o-perret changed the title iam: include policy in role show output iam: include policy in JSON role show output Sep 3, 2026
@natalie-o-perret

Copy link
Copy Markdown
Contributor Author

IMO it feels cluttered, rule expression can also be very long which will extend policy table even more. Probably why policy was factored out in the first place.

Yea, agreed. I updated the PR to keep the default table unchanged and include the nested policy only in JSON output. --policy remains the opt-in full policy table.

@natalie-o-perret natalie-o-perret changed the title iam: include policy in JSON role show output iam: include policy in role show output Sep 3, 2026
@natalie-o-perret
natalie-o-perret merged commit 143e241 into master Sep 3, 2026
7 checks passed
@natalie-o-perret
natalie-o-perret deleted the fix/iam-role-show-policy branch September 3, 2026 12:21
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