-
Notifications
You must be signed in to change notification settings - Fork 42
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
Add commands to manage roles #382
Conversation
de18611
to
b593e63
Compare
237cc46
to
1ecb6fd
Compare
d597f9a
to
a5c8177
Compare
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.
Maybe another changelog is needed for the extra user commands added and possibly the change option name for group commands?
if value == "": | ||
value = "null" |
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.
Does this fix the issue where we can't set some fields back to None
("null") after setting it?
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 is related to the --object
parameter below. Explanation there.
CREATE_ID = "users_roles_create" | ||
DELETE_ID = "users_roles_delete" | ||
NULLABLES = {"content_object"} | ||
user_ctx: PulpUserContext |
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.
Is this not a ClassVar
?
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.
No it it meant to hold a Context instance (with a specific user.pk)
name="remove", | ||
help=_("Revoke a permission from the group."), | ||
decorators=[ | ||
groupname_option, | ||
group_option, | ||
click.option( | ||
"--permission", required=True, callback=_permission_callback, expose_value=False | ||
"--permission", | ||
required=True, | ||
callback=lookup_callback("permission", PulpGroupPermissionContext), | ||
expose_value=False, |
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.
Minor nitpick: should this permission.add_command
call be moved to above the add_permission
method so that it is grouped with the others?
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.
I see add_permission
as one of "the others". They are all subcommands to the same group. And it is just a shame that add_permission
cannot use a generic.
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.
Also in hopefully about 8 releases, this interface is gone anyway. ;)
click.option("--role"), | ||
click.option("--role-in", "role__in"), | ||
click.option("--role-contains", "role__contains"), | ||
click.option("--role-icontains", "role__icontains"), | ||
click.option("--role-startswith", "role__startswith"), | ||
click.option("--object", "content_object", callback=null_callback), |
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.
These are a lot of options. Can some of them be consolidated?
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.
like role_filters
?
pulpcore/cli/core/group.py
Outdated
click.option("--object", "content_object", required=True), | ||
] | ||
), | ||
name="assign", |
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.
We should agree on a consistent name for these actions. Brian was suggesting add/remove for the roles rest mixin pr.
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.
Also, I see this and the remove commands both require --object
to be specified. Are we not allowing users to add/remove model level roles?
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.
We do allow that by specifying --object ""
explicitely. I thought it was too dangerous to assign model level roles whenever the admin just forgot to provide this opttion.
click.option("--locked/--unlocked", default=None), | ||
click.option("--name"), | ||
click.option("--name-in", "name__in"), | ||
click.option("--name-contains", "name__contains"), | ||
click.option("--name-icontains", "name__icontains"), | ||
click.option("--name-startswith", "name__startswith"), |
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.
Lots of options here as well. It's fine if you think we should have them all, I'm just unsure of how useful they all are.
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.
--name-startswith "core."
is probably helpful, as is --name-contains "fileremote"
. About the icontains
i'm not so sure.
click.option( | ||
"--no-permission", | ||
is_eager=True, | ||
is_flag=True, | ||
expose_value=False, | ||
callback=_no_permission_callback, | ||
), | ||
click.option( | ||
"--permission", | ||
"permissions", | ||
multiple=True, | ||
help=_("Permission in the form '<app_label>.<codename>'. Can be used multiple times."), | ||
callback=_permission_callback, | ||
), |
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.
I wonder if this could be implemented as a feature flag. Might remove the need for the _no_permission_callback
. https://click.palletsprojects.com/en/8.0.x/options/#feature-switches
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.
Not sure this would work.
pulpcore/cli/core/role.py
Outdated
@pass_pulp_context | ||
@click.pass_context | ||
def role(ctx: click.Context, pulp_ctx: PulpContext) -> None: | ||
pulp_ctx.needs_plugin(PluginRequirement("core", min="3.16.dev")) |
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.
3.17.dev?
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.
By the time, yes!
click.option( | ||
"--password", | ||
help=_( | ||
"Password for the user. Provide an empty string to disable password authentication." | ||
), | ||
), |
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 we look into the password prompts for this field: https://click.palletsprojects.com/en/8.0.x/options/#password-prompts
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.
I guess, we should.
A change my password command would also be nice.
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.
Would you mind diverting that to a followup PR?
3959e76
to
3a0738d
Compare
[noissue]
This should be fixed by: pulp/pulpcore#1765 |
The CI Failure is a fluke. At some point we should really track down that file repo that keeps failing statistically. |
[noissue]