← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~vaishnavi-asawale/launchpad:fetch-service-charmcraft into launchpad:master

 

Vaishnavi Asawale has proposed merging ~vaishnavi-asawale/launchpad:fetch-service-charmcraft into launchpad:master.

Commit message:
Enable the 'use_fetch_service' option to everyone for charmcraft builds via the API

Previously, the fetch service was only enabled for privileged users (the Golem). Now,
it is available to everyone, in strict and permissive mode.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~vaishnavi-asawale/launchpad/+git/launchpad/+merge/491222
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~vaishnavi-asawale/launchpad:fetch-service-charmcraft into launchpad:master.
diff --git a/lib/lp/charms/interfaces/charmrecipe.py b/lib/lp/charms/interfaces/charmrecipe.py
index a2ae5a0..0399864 100644
--- a/lib/lp/charms/interfaces/charmrecipe.py
+++ b/lib/lp/charms/interfaces/charmrecipe.py
@@ -787,22 +787,6 @@ class ICharmRecipeEditableAttributes(Interface):
         )
     )
 
-
-class ICharmRecipeAdminAttributes(Interface):
-    """`ICharmRecipe` attributes that can be edited by admins.
-
-    These attributes need launchpad.View to see, and launchpad.Admin to change.
-    """
-
-    require_virtualized = exported(
-        Bool(
-            title=_("Require virtualized builders"),
-            required=True,
-            readonly=False,
-            description=_("Only build this charm recipe on virtual builders."),
-        )
-    )
-
     use_fetch_service = exported(
         Bool(
             title=_("Use fetch service"),
@@ -830,6 +814,22 @@ class ICharmRecipeAdminAttributes(Interface):
     )
 
 
+class ICharmRecipeAdminAttributes(Interface):
+    """`ICharmRecipe` attributes that can be edited by admins.
+
+    These attributes need launchpad.View to see, and launchpad.Admin to change.
+    """
+
+    require_virtualized = exported(
+        Bool(
+            title=_("Require virtualized builders"),
+            required=True,
+            readonly=False,
+            description=_("Only build this charm recipe on virtual builders."),
+        )
+    )
+
+
 # XXX cjwatson 2021-09-15 bug=760849: "beta" is a lie to get WADL
 # generation working.  Individual attributes must set their version to
 # "devel".
@@ -871,6 +871,8 @@ class ICharmRecipeSet(Interface):
             "store_upload",
             "store_name",
             "store_channels",
+            "use_fetch_service",
+            "fetch_service_policy",
         ],
     )
     @operation_for_version("devel")
diff --git a/lib/lp/charms/tests/test_charmrecipe.py b/lib/lp/charms/tests/test_charmrecipe.py
index 5d71bd0..a5fb809 100644
--- a/lib/lp/charms/tests/test_charmrecipe.py
+++ b/lib/lp/charms/tests/test_charmrecipe.py
@@ -2190,8 +2190,6 @@ class TestCharmRecipeSet(TestCaseWithFactory):
 
         admin_fields = {
             "require_virtualized": True,
-            "use_fetch_service": True,
-            "fetch_service_policy": FetchServicePolicy.PERMISSIVE,
         }
 
         for field_name, field_value in admin_fields.items():
@@ -2209,8 +2207,6 @@ class TestCharmRecipeSet(TestCaseWithFactory):
         person = self.factory.makePerson()
         admin_fields = {
             "require_virtualized": True,
-            "use_fetch_service": True,
-            "fetch_service_policy": FetchServicePolicy.PERMISSIVE,
         }
 
         for field_name, field_value in admin_fields.items():
@@ -2224,6 +2220,27 @@ class TestCharmRecipeSet(TestCaseWithFactory):
                     field_value,
                 )
 
+    def test_use_fetch_service(self):
+        [ref] = self.factory.makeGitRefs()
+        charm = self.factory.makeCharmRecipe(
+            git_ref=ref, use_fetch_service=False
+        )
+        self.assertEqual(False, charm.use_fetch_service)
+        self.assertEqual(FetchServicePolicy.STRICT, charm.fetch_service_policy)
+        with person_logged_in(charm.owner):
+            charm.use_fetch_service = True
+            charm.fetch_service_policy = FetchServicePolicy.PERMISSIVE
+            self.assertEqual(True, charm.use_fetch_service)
+            self.assertEqual(
+                FetchServicePolicy.PERMISSIVE, charm.fetch_service_policy
+            )
+
+    def test_use_fetch_service_not_passed(self):
+        [ref] = self.factory.makeGitRefs()
+        charm = self.factory.makeCharmRecipe(git_ref=ref)
+        self.assertEqual(False, charm.use_fetch_service)
+        self.assertEqual(FetchServicePolicy.STRICT, charm.fetch_service_policy)
+
 
 class TestCharmRecipeWebservice(TestCaseWithFactory):
     layer = LaunchpadFunctionalLayer

Follow ups