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

Add commands to manage roles #382

Merged
merged 1 commit into from
Dec 9, 2021
Merged

Add commands to manage roles #382

merged 1 commit into from
Dec 9, 2021

Conversation

mdellweg
Copy link
Member

@mdellweg mdellweg commented Sep 30, 2021

[noissue]

  • pulpcore roles must merge first
  • tests

@mdellweg mdellweg mentioned this pull request Sep 30, 2021
@mdellweg mdellweg force-pushed the roles branch 7 times, most recently from de18611 to b593e63 Compare October 7, 2021 13:26
@mdellweg mdellweg force-pushed the roles branch 3 times, most recently from 237cc46 to 1ecb6fd Compare October 16, 2021 20:21
@mdellweg mdellweg force-pushed the roles branch 4 times, most recently from d597f9a to a5c8177 Compare November 19, 2021 10:10
@mdellweg mdellweg marked this pull request as ready for review November 19, 2021 10:13
@mdellweg mdellweg requested review from gerrod3 and ggainey and removed request for gerrod3 November 19, 2021 10:13
Copy link
Contributor

@gerrod3 gerrod3 left a 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?

pulpcore/cli/common/generic.py Outdated Show resolved Hide resolved
Comment on lines +144 to +201
if value == "":
value = "null"
Copy link
Contributor

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?

Copy link
Member Author

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
Copy link
Contributor

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?

Copy link
Member Author

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)

Comment on lines 117 to +125
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,
Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Member Author

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. ;)

Comment on lines +173 to +178
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),
Copy link
Contributor

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

like role_filters?

click.option("--object", "content_object", required=True),
]
),
name="assign",
Copy link
Contributor

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.

Copy link
Contributor

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?

Copy link
Member Author

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.

Comment on lines +38 to +43
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"),
Copy link
Contributor

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.

Copy link
Member Author

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.

Comment on lines +48 to +61
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,
),
Copy link
Contributor

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

Copy link
Member Author

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.

@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"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3.17.dev?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the time, yes!

Comment on lines +38 to +45
click.option(
"--password",
help=_(
"Password for the user. Provide an empty string to disable password authentication."
),
),
Copy link
Contributor

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

Copy link
Member Author

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.

Copy link
Member Author

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?

@mdellweg mdellweg force-pushed the roles branch 5 times, most recently from 3959e76 to 3a0738d Compare December 8, 2021 19:30
@mdellweg
Copy link
Member Author

mdellweg commented Dec 9, 2021

This should be fixed by: pulp/pulpcore#1765

@mdellweg mdellweg added this to the 0.13.0 milestone Dec 9, 2021
@mdellweg
Copy link
Member Author

mdellweg commented Dec 9, 2021

The CI Failure is a fluke. At some point we should really track down that file repo that keeps failing statistically.

@mdellweg mdellweg merged commit df9f5dd into pulp:main Dec 9, 2021
@mdellweg mdellweg deleted the roles branch December 9, 2021 22:16
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