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 href support to resource_option #343

Merged
merged 2 commits into from
Aug 20, 2021
Merged

Conversation

mdellweg
Copy link
Member

fixes #315

@mdellweg
Copy link
Member Author

This is currently only implemented in "pulp file repository *" commands to showcase.

@mdellweg mdellweg added this to the 0.12.0 milestone Aug 17, 2021
pulp_href: Optional[str] = None
entity: Optional[EntityDefinition] = None

if value.startswith("/"):
Copy link
Contributor

@daviddavis daviddavis Aug 17, 2021

Choose a reason for hiding this comment

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

I wonder if this should check for href_pattern instead and then just assume it's a name if it doesn't match:

$ pulp file remote create --name /test/ --url https://fixtures.pulpproject.org/file/
$ pulp file repository create --name /test/ --remote /test/
Error: '/test/' is not a valid href for remote.

Copy link
Member Author

Choose a reason for hiding this comment

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

That wouldn't solve the problem where the name actually looks like a valid href.
But you can always use: $ pulp file repository create --name /test/ --remote ::/test/

@mdellweg mdellweg force-pushed the href_resource branch 2 times, most recently from ec3689e to 736accb Compare August 19, 2021 11:06
@mdellweg
Copy link
Member Author

@daviddavis I extended the use of this feature to all plugins sync and export{,er}s. You might want to revisit.

@daviddavis
Copy link
Contributor

I had one thought (not necessarily for this PR): what if we stored the href_pattern on the context instead of having to define it everywhere?

@mdellweg
Copy link
Member Author

I had one thought (not necessarily for this PR): what if we stored the href_pattern on the context instead of having to define it everywhere?

I'm happy to move it around (to generic?). But for the more generic options, what should be the Context to store it on?

@daviddavis
Copy link
Contributor

Maybe for generic options, the href_pattern must be supplied when calling resource_option?

@mdellweg
Copy link
Member Author

I moved it into the base context. It seemd to match best there.

@@ -16,16 +18,34 @@
from pulpcore.cli.core.context import PulpExportContext, PulpExporterContext

_ = gettext.gettext
REPO_HREF_PATTERN = r"^/pulp/api/v3/repositories/(?P<plugin>\w+)/(?P<resource_type>\w+)/"
Copy link
Contributor

@daviddavis daviddavis Aug 20, 2021

Choose a reason for hiding this comment

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

Why define this here instead of using PulpRepositoryContext.HREF_PATTERN?

Copy link
Member Author

Choose a reason for hiding this comment

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

forgot about that.

@daviddavis
Copy link
Contributor

I was thinking that _option_callback in resource_option would have some logic like:

if href_pattern is None and hasattr(ctx, HREF_PATTERN):
    href_pattern = ctx.HREF_PATTERN

@mdellweg
Copy link
Member Author

I was thinking that _option_callback in resource_option would have some logic like:

if href_pattern is None and hasattr(ctx, HREF_PATTERN):
    href_pattern = ctx.HREF_PATTERN

The problem is, it needs the pattern before determining the Context class to instanciate.

@daviddavis
Copy link
Contributor

Ah, I see. That kind of defeats part of the purpose of my suggestion to have it on context then.

@mdellweg
Copy link
Member Author

Ah, I see. That kind of defeats part of the purpose of my suggestion to have it on context then.

It still feels like the right place.

@mdellweg mdellweg merged commit 6fe109b into pulp:develop Aug 20, 2021
@mdellweg mdellweg deleted the href_resource branch August 20, 2021 16: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.

For sync there's no remote href option nor help text about what's expected for the remote option
2 participants