-
Notifications
You must be signed in to change notification settings - Fork 165
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
Improve cluster|project list-members subcommands #399
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, some minor nits and one thing that I think should be fixed.
func getMemberNameFromPrincipal(principals principalGetter, principalID string) string { | ||
principal, err := principals.ByID(url.PathEscape(principalID)) | ||
if err != nil { | ||
principal = parsePrincipalID(principalID) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this maybe only happen if it's not found? Feels a little odd to show the user details if we got a network error communicating with the cluster?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope. This is deliberate. Up until rancher/rancher#47702 this endpoint always returned 500. And the fix is not backported yet. But more importantly there is no reason to break the whole command (that lists {C|P}RTB's) just because we can't look up a principal. We can do the next best thing - parse the principal name and produce the output. More over I think that's what UI should do too.
|
||
err := listProjectMembers(cctx, &out, userConfig, prtbs, principals) | ||
require.NoError(t, err) | ||
require.NotEmpty(t, out) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: you don't need require.NotEmpty(t, out)
as you have a deeper assertion below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was intentional. There is no need to do any other work if the output is empty. This assertion is cheap.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love the changes, and tests. Thanks!
FocusedProject() string | ||
} | ||
|
||
func listClusterMembers(ctx *cli.Context, out io.Writer, config userConfig, crtbs crtbLister, principals principalGetter) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great change for testability
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, addresses the original issue and makes things a lot better overall...and adds tests.
Do not merge: this is slated for v2.11. |
Ref: rancher/rancher#47692