-
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
Added label command to ansible distribution #186
Conversation
pulpcore/cli/ansible/distribution.py
Outdated
@@ -79,6 +80,7 @@ def distribution(ctx: click.Context, pulp_ctx: PulpContext, distribution_type: s | |||
distribution.add_command(show_command(decorators=lookup_options)) | |||
distribution.add_command(destroy_command(decorators=lookup_options)) | |||
distribution.add_command(create_command(decorators=create_options)) | |||
distribution.add_command(label_command()) |
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 added in an upcoming pulp_ansible version, right?
Can we pass a list of needed plugins with versions to the label_command
generator?
And than we should have a test that can excercise this at least on the nightly container.
2818ea8
to
2c62fe6
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.
This exactly what i dreamed of. 🚀
I just want some variables to be renamed.
pulpcore/cli/common/generic.py
Outdated
@@ -390,10 +390,15 @@ def label_command(**kwargs: Any) -> click.Command: | |||
if "name" not in kwargs: | |||
kwargs["name"] = "label" | |||
decorators = kwargs.pop("decorators", [name_option, href_option]) | |||
needs = kwargs.pop("needs", [("core", "3.10.0")]) |
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'd prefer a more descriptive name: need_plugins
, needed_plugins
, ...
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.
For both the kwargs and the variable name?
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.
Yes. Sure they should be the same.
Which one do you prefer?
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.
need_plugins
pulpcore/cli/common/generic.py
Outdated
min_ver = plugin[1] if len(plugin) >= 2 else None | ||
max_ver = plugin[2] if len(plugin) == 3 else None | ||
pulp_ctx.needs_plugin(plugin[0], min_ver, max_ver) |
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 can do something fancy with a namedtuple here. But maybe not today...
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.
Ask and you shall receive.
65e604b
to
6885ef8
Compare
pulpcore/cli/common/generic.py
Outdated
for item in need_plugins: | ||
pulp_ctx.needs_plugin(item.name, item.min, item.max) |
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 this work?
for item in need_plugins: | |
pulp_ctx.needs_plugin(item.name, item.min, item.max) | |
for item in need_plugins: | |
pulp_ctx.needs_plugin(*item) |
or this?
for item in need_plugins: | |
pulp_ctx.needs_plugin(item.name, item.min, item.max) | |
[pulp_ctx.needs_plugin(*item) for item in need_plugins] |
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.
- Yes if I edit the tuple. 2. Yes if I edit the tuple, but mypy does not like it since
needs_plugin
doesn't return anything.
(edit) NVM, don't need to edit the tuple since the args are in the same order I declared the name fields.
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.
yep, i agree the latter is rather unintuive. Usually you use list comprehensions that do not have side effects. This would be only using the side effect.
6885ef8
to
bdaccfa
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.
Is ansible 0.8.0 containing that feature in the nightly container already?
I merged the ansible labels feature Wednesday, so it should I think. |
fixes: #185