Skip to content

Commit

Permalink
Make the pagure namespace for 'flatpaks' configurable
Browse files Browse the repository at this point in the history
The previous change to look up Flatpaks under 'flatpaks/' rather than
'modules/' was backwards incompatible - to restore compatibility, make
this a new config setting: pagure_flatpak_namespace.

Signed-off-by: Owen W. Taylor <otaylor@fishsoup.net>
(cherry picked from commit 0e73eb5)

# Conflicts:
#	bodhi/server/config.py
#	bodhi/server/models.py
#	bodhi/tests/server/test_models.py
  • Loading branch information
owtaylor authored and mergify-bot committed Mar 26, 2019
1 parent 7e780c7 commit 613f37e
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 4 deletions.
7 changes: 7 additions & 0 deletions bodhi/server/config.py
Expand Up @@ -526,7 +526,14 @@ class BodhiConfig(dict):
'validator': six.text_type},
'openid_template': {
'value': '{username}.id.fedoraproject.org',
<<<<<<< HEAD
'validator': six.text_type},
=======
'validator': str},
'pagure_flatpak_namespace': {
'value': 'modules',
'validator': str},
>>>>>>> 0e73eb54f... Make the pagure namespace for 'flatpaks' configurable
'pagure_url': {
'value': 'https://src.fedoraproject.org/pagure/',
'validator': _validate_tls_url},
Expand Down
7 changes: 6 additions & 1 deletion bodhi/server/models.py
Expand Up @@ -1100,11 +1100,16 @@ def get_pkg_committers_from_pagure(self):
"""
pagure_url = config.get('pagure_url')
# Pagure uses plural names for its namespaces such as "rpms" except for
# container. Flatpaks build directly from the 'modules' namespace
# container. Flatpaks were moved from 'modules' to 'flatpaks' - hence
# a config setting.
if self.type.name == 'container':
namespace = self.type.name
elif self.type.name == 'flatpak':
<<<<<<< HEAD
namespace = 'modules'
=======
namespace = config.get('pagure_flatpak_namespace')
>>>>>>> 0e73eb54f... Make the pagure namespace for 'flatpaks' configurable
else:
namespace = self.type.name + 's'
package_pagure_url = '{0}/api/0/{1}/{2}?expand_group=1'.format(
Expand Down
28 changes: 25 additions & 3 deletions bodhi/tests/server/test_models.py
Expand Up @@ -1052,9 +1052,8 @@ class TestFlatpakPackage(ModelTest, unittest.TestCase):
klass = model.FlatpakPackage
attrs = dict(name=u"flatpak-runtime")

@mock.patch('bodhi.server.util.http_session')
def test_get_pkg_committers_from_pagure(self, http_session):
"""Ensure correct return value from get_pkg_committers_from_pagure()."""
def patch_http_session(self, http_session, namespace):
"""Patch in the correct pagure API result for the particular flatpaks namespace."""
json_output = {
"access_groups": {
"admin": [],
Expand All @@ -1073,7 +1072,11 @@ def test_get_pkg_committers_from_pagure(self, http_session):
"custom_keys": [],
"date_created": "1494947106",
"description": "Flatpak Runtime",
<<<<<<< HEAD
"fullname": "modules/flatpak-runtime",
=======
"fullname": namespace + "/flatpak-runtime",
>>>>>>> 0e73eb54f... Make the pagure namespace for 'flatpaks' configurable
"group_details": {},
"id": 2,
"milestones": {},
Expand All @@ -1090,6 +1093,25 @@ def test_get_pkg_committers_from_pagure(self, http_session):
http_session.get.return_value.json.return_value = json_output
http_session.get.return_value.status_code = 200
@mock.patch('bodhi.server.util.http_session')
def test_get_pkg_committers_from_pagure_modules(self, http_session):
"""Ensure correct return value from get_pkg_committers_from_pagure()."""
self.patch_http_session(http_session, namespace='modules')
rv = self.obj.get_pkg_committers_from_pagure()
self.assertEqual(rv, (['otaylor'], []))
http_session.get.assert_called_once_with(
('https://src.fedoraproject.org/pagure/api/0/modules/flatpak-runtime'
'?expand_group=1'),
timeout=60)
@mock.patch.dict('bodhi.server.config.config', {'pagure_flatpak_namespace': 'flatpaks'})
@mock.patch('bodhi.server.util.http_session')
def test_get_pkg_committers_from_pagure_flatpaks(self, http_session):
"""Check that the pagure_flatpak_namespace config key works."""
self.patch_http_session(http_session, namespace='flatpaks')
rv = self.obj.get_pkg_committers_from_pagure()
self.assertEqual(rv, (['otaylor'], []))
Expand Down
4 changes: 4 additions & 0 deletions production.ini
Expand Up @@ -367,6 +367,10 @@ use = egg:bodhi-server
##
# pagure_url = https://src.fedoraproject.org/pagure/

# This is the namespace where we expect to find the git sources for a Flatpak.
# The default - 'modules' instead of 'flatpaks' - is for backward compatibility
# pagure_flatpak_namespace = modules

##
## Product Definition Center (PDC)
##
Expand Down

0 comments on commit 613f37e

Please sign in to comment.