Merge ~twom/launchpad:oci-recipe-push-rules-api into launchpad:master

Proposed by Tom Wardill
Status: Merged
Approved by: Tom Wardill
Approved revision: ffc235f486ee1797cb0a5cae78e1074cfb9b482c
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~twom/launchpad:oci-recipe-push-rules-api
Merge into: launchpad:master
Diff against target: 59 lines (+24/-5)
2 files modified
lib/lp/oci/interfaces/ocirecipe.py (+2/-2)
lib/lp/oci/tests/test_ocirecipe.py (+22/-3)
Reviewer Review Type Date Requested Status
Colin Watson (community) Approve
Review via email: mp+382771@code.launchpad.net

Commit message

Add push_rules to the export of recipe

Description of the change

Push Rules should be available from the recipe, they currently aren't.
Export the attribute an API user can retrieve relevant push rules.

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/lib/lp/oci/interfaces/ocirecipe.py b/lib/lp/oci/interfaces/ocirecipe.py
index 4562687..dbaf087 100644
--- a/lib/lp/oci/interfaces/ocirecipe.py
+++ b/lib/lp/oci/interfaces/ocirecipe.py
@@ -209,12 +209,12 @@ class IOCIRecipeView(Interface):
209 :return: `IOCIRecipeBuild`.209 :return: `IOCIRecipeBuild`.
210 """210 """
211211
212 push_rules = CollectionField(212 push_rules = exported(CollectionField(
213 title=_("Push rules for this OCI recipe."),213 title=_("Push rules for this OCI recipe."),
214 description=_("All of the push rules for registry upload "214 description=_("All of the push rules for registry upload "
215 "that apply to this recipe."),215 "that apply to this recipe."),
216 # Really IOCIPushRule, patched in _schema_cirular_imports.216 # Really IOCIPushRule, patched in _schema_cirular_imports.
217 value_type=Reference(schema=Interface), readonly=True)217 value_type=Reference(schema=Interface), readonly=True))
218218
219 can_upload_to_registry = Bool(219 can_upload_to_registry = Bool(
220 title=_("Can upload to registry"), required=True, readonly=True,220 title=_("Can upload to registry"), required=True, readonly=True,
diff --git a/lib/lp/oci/tests/test_ocirecipe.py b/lib/lp/oci/tests/test_ocirecipe.py
index 4c8a126..833a675 100644
--- a/lib/lp/oci/tests/test_ocirecipe.py
+++ b/lib/lp/oci/tests/test_ocirecipe.py
@@ -39,9 +39,6 @@ from lp.oci.interfaces.ocirecipe import (
39 OCIRecipeNotOwner,39 OCIRecipeNotOwner,
40 )40 )
41from lp.oci.interfaces.ocirecipebuild import IOCIRecipeBuildSet41from lp.oci.interfaces.ocirecipebuild import IOCIRecipeBuildSet
42from lp.oci.interfaces.ociregistrycredentials import (
43 OCIRegistryCredentialsAlreadyExist,
44 )
45from lp.oci.tests.helpers import OCIConfigHelperMixin42from lp.oci.tests.helpers import OCIConfigHelperMixin
46from lp.services.config import config43from lp.services.config import config
47from lp.services.database.constants import (44from lp.services.database.constants import (
@@ -763,3 +760,25 @@ class TestOCIRecipeWebservice(OCIConfigHelperMixin, TestCaseWithFactory):
763 new_obj_url = resp.getHeader("Location")760 new_obj_url = resp.getHeader("Location")
764 ws_push_rule = self.load_from_api(new_obj_url)761 ws_push_rule = self.load_from_api(new_obj_url)
765 self.assertEqual(obj["image_name"], ws_push_rule["image_name"])762 self.assertEqual(obj["image_name"], ws_push_rule["image_name"])
763
764 def test_api_push_rules_exported(self):
765 """Are push rules exported for a recipe?"""
766 self.setConfig()
767
768 image_name = self.factory.getUniqueUnicode()
769
770 with person_logged_in(self.person):
771 oci_project = self.factory.makeOCIProject(
772 registrant=self.person)
773 recipe = self.factory.makeOCIRecipe(
774 oci_project=oci_project, owner=self.person,
775 registrant=self.person)
776 push_rule = self.factory.makeOCIPushRule(
777 recipe=recipe, image_name=image_name)
778 url = api_url(recipe)
779
780 ws_recipe = self.load_from_api(url)
781 push_rules = self.load_from_api(
782 ws_recipe["push_rules_collection_link"])
783 self.assertEqual(
784 image_name, push_rules["entries"][0]["image_name"])

Subscribers

People subscribed via source and target branches

to status/vote changes: