-
Notifications
You must be signed in to change notification settings - Fork 53
Skip the publish and create directly the publication. #334
Conversation
f1a2a44
to
ce0cc34
Compare
@pulp/qe please also review pulp/pulp-smash#1194 |
@@ -77,21 +68,13 @@ def test_all(self): | |||
non_latest = choice(version_hrefs[:-1]) | |||
|
|||
# Step 2 | |||
publication = publish(self.cfg, publisher, repo) | |||
publication1 = publication(self.cfg, DOCKER_PUBLICATION_PATH, repo) |
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.
Pulp-Smash now has a task_handler
it was added recently in pulp/pulp-smash#1184
Now you don't need that extra publication
function and can simply do
publication1 = self.client.using_handler(api.task_handler).post(
DOCKER_PUBLICATION_PATH,
data={"repository": repo["_href"]}
)
The above post
response will be passed to api.task_handler
which will do exactly what your publication
function is doing see: https://github.com/PulpQE/pulp-smash/blob/master/pulp_smash/api.py#L205-L268
@rochacbruno i updated the code and closed the opened PR, task_handler covers the usecase we need. |
pulp_docker/app/viewsets.py
Outdated
kwargs={ | ||
'publisher_pk': str(publisher.pk), | ||
'repository_version_pk': str(repository_version.pk) |
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.
super duper nit: with the other line gone, it would be nice to put all the kwargs on a single line.
@@ -148,42 +149,40 @@ def sync(self, request, pk): | |||
return OperationPostponedResponse(result, request) | |||
|
|||
|
|||
class DockerPublisherViewSet(PublisherViewSet): | |||
class DockerPublicationViewSet(NamedModelViewSet, mixins.CreateModelMixin): |
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 think this should probably also have these mixins: [list, read, delete]
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.
just create, this is a custom endpoint
pulp_docker/app/viewsets.py
Outdated
endpoint_name = 'docker' | ||
queryset = models.DockerPublisher.objects.all() | ||
serializer_class = serializers.DockerPublisherSerializer | ||
endpoint_name = 'docker/publications' |
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 think this endpoint should be publications/docker. This is closer to the truth, the object is created is a publication, and the returned value of a /v3/publication will be less surprising.
Its worth noting that all the master/detail endpoints are structured in this way, ie content/docker remotes/docker
a345360
to
6fcbffd
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.
I just noticed one potential surprise. I think this endpoint can publish any repository version, not just docker ones.
Hopefully people won't do that?
However we go, this is an improvement, +1 to merge
README.rst
Outdated
|
||
Use the ``bar`` Publisher to create a Publication | ||
Create a Publication |
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.
Given the new endpoint name, I think we should call this "publish a repository version"
closes #4378
https://pulp.plan.io/issues/4378