Vaishnavi Asawale has proposed merging ~vaishnavi-asawale/launchpad/+git/launchpad-1:move-fetch-service-button into launchpad:master.
Commit message: Move 'Use fetch Service' button from Administer recipe to Edit recipe for snaps The user can initiate a snap build with the fetch service enabled (strict mode default) from the Edit recipe page. Requested reviews: Launchpad code reviewers (launchpad-reviewers) For more details, see: https://code.launchpad.net/~vaishnavi-asawale/launchpad/+git/launchpad-1/+merge/490093 -- Your team Launchpad code reviewers is requested to review the proposed merge of ~vaishnavi-asawale/launchpad/+git/launchpad-1:move-fetch-service-button into launchpad:master.
diff --git a/lib/lp/snappy/browser/snap.py b/lib/lp/snappy/browser/snap.py index dc4d330..a65b679 100644 --- a/lib/lp/snappy/browser/snap.py +++ b/lib/lp/snappy/browser/snap.py @@ -77,7 +77,6 @@ from lp.snappy.browser.widgets.snaparchive import SnapArchiveWidget from lp.snappy.browser.widgets.storechannels import StoreChannelsWidget from lp.snappy.interfaces.snap import ( SNAP_SNAPCRAFT_CHANNEL_FEATURE_FLAG, - SNAP_USE_FETCH_SERVICE_FEATURE_FLAG, CannotAuthorizeStoreUploads, CannotFetchSnapcraftYaml, CannotParseSnapcraftYaml, @@ -550,6 +549,8 @@ class ISnapEditSchema(Interface): store_name = copy_field(ISnap["store_name"], required=True) store_channels = copy_field(ISnap["store_channels"], required=True) + use_fetch_service = copy_field(ISnap["use_fetch_service"], required=True) + def log_oops(error, request): """Log an oops report without raising an error.""" @@ -941,9 +942,6 @@ class SnapAdminView(BaseSnapEditView): "pro_enable", ] - if getFeatureFlag(SNAP_USE_FETCH_SERVICE_FEATURE_FLAG): - fields.append("use_fetch_service") - return fields @property @@ -988,6 +986,7 @@ class SnapEditView(BaseSnapEditView, EnableProcessorsMixin): "store_upload", "store_name", "store_channels", + "use_fetch_service", ] custom_widget_store_distro_series = LaunchpadRadioWidget custom_widget_vcs = LaunchpadRadioWidget diff --git a/lib/lp/snappy/browser/tests/test_snap.py b/lib/lp/snappy/browser/tests/test_snap.py index 819d770..a0253ab 100644 --- a/lib/lp/snappy/browser/tests/test_snap.py +++ b/lib/lp/snappy/browser/tests/test_snap.py @@ -61,7 +61,6 @@ from lp.snappy.browser.snap import ( ) from lp.snappy.interfaces.snap import ( SNAP_SNAPCRAFT_CHANNEL_FEATURE_FLAG, - SNAP_USE_FETCH_SERVICE_FEATURE_FLAG, CannotModifySnapProcessor, ISnapSet, SnapBuildRequestStatus, @@ -821,10 +820,6 @@ class TestSnapAdminView(BaseTestSnapView): def test_admin_snap(self): # Admins can change require_virtualized, privacy, and allow_internet. - self.useFixture( - FeatureFixture({SNAP_USE_FETCH_SERVICE_FEATURE_FLAG: True}) - ) - login("ad...@canonical.com") admin = self.factory.makePerson( member_of=[getUtility(ILaunchpadCelebrities).admin] @@ -852,39 +847,14 @@ class TestSnapAdminView(BaseTestSnapView): browser.getControl(name="field.information_type").value = private browser.getControl("Allow external network access").selected = False browser.getControl("Enable Ubuntu Pro").selected = True - browser.getControl("Use fetch service").selected = True browser.getControl("Update snap package").click() - # XXX ines-almeida 2024-03-11: Browser tests work oddly with fixtures. - # This ensures that the feature flag is ON during the rest of the test. - # Further investigation on this issue is required. - self.useFixture( - FeatureFixture({SNAP_USE_FETCH_SERVICE_FEATURE_FLAG: True}) - ) login_admin() self.assertEqual(project, snap.project) self.assertFalse(snap.require_virtualized) self.assertTrue(snap.private) self.assertFalse(snap.allow_internet) self.assertTrue(snap.pro_enable) - self.assertTrue(snap.use_fetch_service) - - def test_admin_use_fetch_service_feature_flag(self): - admin = self.factory.makePerson( - member_of=[getUtility(ILaunchpadCelebrities).admin] - ) - snap = self.factory.makeSnap(registrant=admin) - browser = self.getViewBrowser(snap, user=admin) - - browser.getLink("Administer snap package").click() - self.assertFalse("Use fetch service" in browser.contents) - - self.useFixture( - FeatureFixture({SNAP_USE_FETCH_SERVICE_FEATURE_FLAG: True}) - ) - - browser.reload() - self.assertTrue("Use fetch service" in browser.contents) def test_admin_snap_private_without_project(self): # Cannot make snap private if it doesn't have a project associated. @@ -1458,6 +1428,34 @@ class TestSnapEditView(BaseTestSnapView): MatchesTagText(content, "source"), ) + def test_use_fetch_service_feature_flag(self): + series = self.factory.makeUbuntuDistroSeries() + with admin_logged_in(): + snappy_series = self.factory.makeSnappySeries( + usable_distro_series=[series] + ) + ref = self.factory.makeGitRefRemote() + snap = self.factory.makeSnap( + registrant=self.person, + owner=self.person, + distroseries=series, + git_ref=ref, + store_series=snappy_series, + ) + browser = self.getViewBrowser(snap, user=self.person) + self.assertFalse("Use fetch service" in browser.contents) + browser.getLink("Edit snap package").click() + + # XXX ines-almeida 2024-03-11: Browser tests work oddly with fixtures. + # This ensures that the feature flag is ON during the rest of the test. + # Further investigation on this issue is required. + # self.useFixture( + # FeatureFixture({SNAP_USE_FETCH_SERVICE_FEATURE_FLAG: True}) + # ) + + browser.reload() + self.assertTrue("Use fetch service" in browser.contents) + def setUpSeries(self): """Set up {distro,snappy}series with some available processors.""" distroseries = self.factory.makeUbuntuDistroSeries() diff --git a/lib/lp/snappy/interfaces/snap.py b/lib/lp/snappy/interfaces/snap.py index 684c280..c0a724c 100644 --- a/lib/lp/snappy/interfaces/snap.py +++ b/lib/lp/snappy/interfaces/snap.py @@ -19,6 +19,7 @@ __all__ = [ "ISnapDelete", "ISnapSet", "ISnapView", + "ISnapEditableAttributes", "MissingSnapcraftYaml", "NoSourceForSnap", "NoSuchSnap", @@ -1140,6 +1141,32 @@ class ISnapEditableAttributes(IHasOwner): ) ) + use_fetch_service = exported( + Bool( + title=_("Use fetch service"), + required=True, + readonly=False, + description=_( + "If set, Snap builds will use the fetch-service instead " + "of the builder-proxy to access external resources." + ), + ) + ) + + fetch_service_policy = exported( + Choice( + title=_("Fetch service policy"), + vocabulary=FetchServicePolicy, + required=False, + readonly=False, + default=FetchServicePolicy.STRICT, + description=_( + "Which policy to use when using the fetch service. Ignored if " + "`use_fetch_service` flag is False." + ), + ) + ) + def setProject(project): """Set the pillar project of this snap recipe.""" @@ -1194,32 +1221,6 @@ class ISnapAdminAttributes(Interface): ) ) - use_fetch_service = exported( - Bool( - title=_("Use fetch service"), - required=True, - readonly=False, - description=_( - "If set, Snap builds will use the fetch-service instead " - "of the builder-proxy to access external resources." - ), - ) - ) - - fetch_service_policy = exported( - Choice( - title=_("Fetch service policy"), - vocabulary=FetchServicePolicy, - required=False, - readonly=False, - default=FetchServicePolicy.STRICT, - description=_( - "Which policy to use when using the fetch service. Ignored if " - "`use_fetch_service` flag is False." - ), - ) - ) - def subscribe(person, subscribed_by): """Subscribe a person to this snap recipe.""" diff --git a/lib/lp/snappy/templates/snap-edit.pt b/lib/lp/snappy/templates/snap-edit.pt index ad92312..fdf92ec 100644 --- a/lib/lp/snappy/templates/snap-edit.pt +++ b/lib/lp/snappy/templates/snap-edit.pt @@ -133,6 +133,11 @@ <tal:widget define="widget nocall:view/widgets/processors"> <metal:block use-macro="context/@@launchpad_form/widget_row" /> </tal:widget> + + <tal:widget define="widget nocall:view/widgets/use_fetch_service"> + <metal:block use-macro="context/@@launchpad_form/widget_row" /> + </tal:widget> + </table> </metal:formbody> </div>
_______________________________________________ Mailing list: https://launchpad.net/~launchpad-reviewers Post to : launchpad-reviewers@lists.launchpad.net Unsubscribe : https://launchpad.net/~launchpad-reviewers More help : https://help.launchpad.net/ListHelp