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

Added label command to ansible distribution #186

Merged
merged 1 commit into from
Mar 27, 2021

Conversation

gerrod3
Copy link
Contributor

@gerrod3 gerrod3 commented Mar 23, 2021

fixes: #185

@@ -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())
Copy link
Member

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.

@gerrod3 gerrod3 force-pushed the ansible_distribution_labels branch 2 times, most recently from 2818ea8 to 2c62fe6 Compare March 25, 2021 20:09
Copy link
Member

@mdellweg mdellweg left a 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.

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

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, ...

Copy link
Contributor Author

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?

Copy link
Member

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?

Copy link
Contributor Author

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 Show resolved Hide resolved
Comment on lines 399 to 401
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)
Copy link
Member

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

Copy link
Contributor Author

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.

@gerrod3 gerrod3 force-pushed the ansible_distribution_labels branch 2 times, most recently from 65e604b to 6885ef8 Compare March 26, 2021 15:07
Comment on lines 404 to 405
for item in need_plugins:
pulp_ctx.needs_plugin(item.name, item.min, item.max)
Copy link
Member

Choose a reason for hiding this comment

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

Would this work?

Suggested change
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?

Suggested change
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]

Copy link
Contributor Author

@gerrod3 gerrod3 Mar 26, 2021

Choose a reason for hiding this comment

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

  1. 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.

Copy link
Member

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.

@gerrod3 gerrod3 force-pushed the ansible_distribution_labels branch from 6885ef8 to bdaccfa Compare March 26, 2021 16:01
Copy link
Member

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

@gerrod3
Copy link
Contributor Author

gerrod3 commented Mar 26, 2021

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.

@mdellweg mdellweg added this to the 0.8.0 milestone Mar 27, 2021
@mdellweg mdellweg merged commit 5e919f5 into pulp:develop Mar 27, 2021
@gerrod3 gerrod3 deleted the ansible_distribution_labels branch March 30, 2021 14:20
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.

Add label command to ansible distributions
2 participants