<div dir="ltr"><div><div>I am responding on the list because this seems like a problem that other plugins will also face. <br><br>It seems like there are 2 possible solutions here. <br><br>1) pulp_docker could provide a custom REST api endpoint that will provide 'tagging' functionality. This API would perform all the validation needed and then create a new repository version with all the proper tags.<br><br></div>2) pulpcore's v3/repositories/<wbr>1234/versions/  endpoint could provide a way for plugins to provide custom behavior.<br><br></div>I have advocated for 2 in the past  and I continue to believe that the repository versions API should take an 'action' or 'operation' parameter that would map to some functionality provided by a plugin. <br><br><div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Mar 6, 2018 at 4:03 PM, Austin Macdonald <span dir="ltr"><<a href="mailto:austin@redhat.com" target="_blank">austin@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Concept:</div><div>ContentUnits are created with a POST request to /v3/content/<type>/. Adding the Tag to a Repository is a separate call. This workflow is awkward for Tags because we would need to set the "repository" field on the Tag in the first call, and actually add it to the repository in a second call. The first call won't have enough information to enforce the uniqueness constraints due to repository versions. The second call won't work either, because adding content units to a repository is strictly a pulpcore endpoint, and does not offer plugins the ability to enforce uniqueness constraints. In Pulp 2, we enforced "only 1 tag of name X, type Y, repository Z" with unique together, but this cannot work anymore because of RepositoryVersions, because Tags created for old RepositoryVersions still exist after they are removed from a later version.</div><div><br></div><div>Example:<br></div><div>We have a Repository, myrepo, and 2 manifests, m1 and m2. We put m1 in myrepo.</div><div>myrepov1 = [m1]</div><div>Then we create a tag t1 = Tag("latest", m1, myrepo) and we add it to myrepo.</div><div>myrepov2 = [m1, t1]</div><div><br></div><div>Then we add m2 to myrepo.</div><div>myrepov3 = [m1, t1, m2]</div><div><br></div><div>Then it gets interesting. Can we create t2 = Tag("latest", m2, myrepo)?</div><div><br></div><div>We can remove t1 from myrepo, (but we have to leave the tag unchanged to preserve old repo versions), which means that yes, t2 is a valid tag.</div><div><br></div><div>Now we have a problem. Without removing t1, we can add t2 to myrepo, and the docker plugin is powerless to stop it because the endpoint v3/repositories/1234/versions/ does not involve plugins. We don't have the ability to validate uniqueness within a repository.</div></div>
</blockquote></div><br></div></div></div>