From 247bebd48ea8ab1797e35d90c1812888a19fc540 Mon Sep 17 00:00:00 2001 From: Giulia Naponiello Date: Nov 13 2019 10:21:27 +0000 Subject: [PATCH 1/2] Drop configrh since it's not used anymore Signed-off-by: Giulia Naponiello --- diff --git a/conf/configrh.py b/conf/configrh.py deleted file mode 100644 index 9b8e0b4..0000000 --- a/conf/configrh.py +++ /dev/null @@ -1,135 +0,0 @@ -# -*- coding: utf-8 -*- - -import os - -from conf import config - - -class BaseConfiguration(config.BaseConfiguration): - MESSAGING_TOPIC_PREFIX = [ - # This is the queue name to receive messages from UMB. - # Generally, it has format Consumer.client-[name].*.VirtualTopic.> - # - # - name is deteremined by the certificate requested. For example, a - # certificate is requested with client name msg-client-bob, then in - # queue name, it name should be bob, that is Consumer.client-bob. - # - # - * is any word you choose, which should be descriptive to this queue - # - # - > represents the hierarchy of topic name, e.g. eng.brew.sign.rpm - os.environ['FRESHMAKER_MESSAGING_TOPIC_PREFIX'], - ] - - PARSERS = [ - 'freshmaker.parsers.brew.sign_rpm:BrewSignRpmParser', - 'freshmaker.parsers.brew:BrewTaskStateChangeParser', - ] - - HANDLERS = [ - 'freshmaker.handlers.brew:BrewSignRPMHandler', - 'freshmaker.handlers.brew:BrewContainerTaskStateChangeHandler', - ] - - KOJI_PROFILE = 'brew' - - # LightBlue server URL, e.g. http://localhost/ - LIGHTBLUE_SERVER_URL = '' # replace with default server url - LIGHTBLUE_VERIFY_SSL = True - # Path to LightBlue certificate file - LIGHTBLUE_CERTIFICATE = '' - # Path to LightBlue private key file - LIGHTBLUE_PRIVATE_KEY = '' - - # Lookup versions of each entity: /rest/metadata/{entity name} - LIGHTBLUE_ENTITY_VERSIONS = { - 'containerRepository': '0.0.11', - 'containerImage': '0.0.12', - } - - # replace with real value when deploy - ERRATA_TOOL_SERVER_URL = '' - - # replace with real value when deploy - SFM2_API_URL = '' - - # Pulp server url, e.g. http://localhost/ - PULP_SERVER_URL = '' - - # Username and password used to query Pulp server - PULP_USERNAME = '' - PULP_PASSWORD = '' - - AUTH_BACKEND = 'kerberos' - # Replace with real ldap server URL - AUTH_LDAP_SERVER = '' - AUTH_LDAP_USER_BASE = 'ou=users,dc=redhat,dc=com' - - HANDLER_BUILD_WHITELIST = { - 'BrewSignRPMHandler': { - 'image': [ - { - 'advisory_state': 'SHIPPED_LIVE', - }, - ], - }, - 'ErrataAdvisoryStateChangedHandler': { - 'image': [ - { - 'advisory_state': 'SHIPPED_LIVE', - }, - ], - }, - } - - -class DevConfiguration(BaseConfiguration): - DEBUG = True - LOG_BACKEND = 'console' - LOG_LEVEL = 'debug' - - # Global network-related values, in seconds - NET_TIMEOUT = 5 - NET_RETRY_INTERVAL = 1 - - KOJI_CONTAINER_SCRATCH_BUILD = True - - LIGHTBLUE_VERIFY_SSL = False - - HANDLER_BUILD_WHITELIST = { - 'BrewSignRPMHandler': { - 'image': [ - { - 'advisory_state': 'REL_PREP|PUSH_READY|IN_PUSH|SHIPPED_LIVE', - }, - ], - }, - 'ErrataAdvisoryStateChangedHandler': { - 'image': [ - { - 'advisory_state': 'REL_PREP|PUSH_READY|IN_PUSH|SHIPPED_LIVE', - }, - ], - }, - } - - -class TestConfiguration(BaseConfiguration): - LOG_BACKEND = 'console' - LOG_LEVEL = 'debug' - DEBUG = True - - SQLALCHEMY_DATABASE_URI = 'sqlite:///{0}'.format( - os.path.join(config.dbdir, 'tests', 'test_freshmaker.db')) - - MESSAGING = 'in_memory' - PDC_URL = 'http://pdc.fedoraproject.org/rest_api/v1' - - # Global network-related values, in seconds - NET_TIMEOUT = 3 - NET_RETRY_INTERVAL = 1 - MBS_AUTH_TOKEN = "testingtoken" - - KOJI_CONTAINER_SCRATCH_BUILD = True - - LIGHTBLUE_SERVER_URL = '' # replace with real dev server url - LIGHTBLUE_VERIFY_SSL = False From 0ca3ed9239163688e5b03a9b43b65a0f9cae0c4d Mon Sep 17 00:00:00 2001 From: Giulia Naponiello Date: Nov 13 2019 10:53:58 +0000 Subject: [PATCH 2/2] Move hardcoded release categories to conf Signed-off-by: Giulia Naponiello --- diff --git a/freshmaker/config.py b/freshmaker/config.py index e581eaa..c7bbbd0 100644 --- a/freshmaker/config.py +++ b/freshmaker/config.py @@ -364,6 +364,11 @@ class Config(object): 'default': '', 'desc': 'A suffix to add to the rebuilt_nvr release in addition to the timestamp.', }, + 'lightblue_release_categories': { + 'type': tuple, + 'default': ("Generally Available", "Tech Preview", "Beta",), + 'desc': 'Release categories', + } } def __init__(self, conf_section_obj): @@ -414,7 +419,7 @@ class Config(object): if key in self._defaults: # type conversion for configuration item convert = self._defaults[key]['type'] - if convert in [bool, int, list, str, set, dict]: + if convert in [bool, int, list, str, set, dict, tuple]: try: # Do no try to convert None... if value is not None: diff --git a/freshmaker/handlers/koji/rebuild_images_on_rpm_advisory_change.py b/freshmaker/handlers/koji/rebuild_images_on_rpm_advisory_change.py index e7d61aa..2a12a93 100644 --- a/freshmaker/handlers/koji/rebuild_images_on_rpm_advisory_change.py +++ b/freshmaker/handlers/koji/rebuild_images_on_rpm_advisory_change.py @@ -399,7 +399,7 @@ class RebuildImagesOnRPMAdvisoryChange(ContainerBuildHandler): # published and release_categories if so. if self.event.is_allowed(self, published=True): published = True - release_categories = ("Generally Available", "Tech Preview", "Beta",) + release_categories = conf.lightblue_release_categories else: published = None release_categories = None diff --git a/freshmaker/image_verifier.py b/freshmaker/image_verifier.py index 12a4a9d..58c75a1 100644 --- a/freshmaker/image_verifier.py +++ b/freshmaker/image_verifier.py @@ -44,7 +44,7 @@ class ImageVerifier(object): Verifies the Lightblue ContainerRepository data. Raises ValueError in case of error. """ - categories = set(["Generally Available", "Tech Preview", "Beta"]) + categories = set(conf.lightblue_release_categories) if not set(repo["release_categories"]).intersection(categories): raise ValueError( "Only repositories with one of %r release_categories can be " diff --git a/freshmaker/lightblue.py b/freshmaker/lightblue.py index 1eb7024..c83746a 100644 --- a/freshmaker/lightblue.py +++ b/freshmaker/lightblue.py @@ -635,7 +635,7 @@ class LightBlue(object): def _set_container_repository_filters( self, request, published=True, - release_categories=("Generally Available", "Tech Preview", "Beta",)): + release_categories=conf.lightblue_release_categories): """ Sets the additional filters to containerRepository request based on the self.published, self.release_categories attributes. @@ -664,7 +664,7 @@ class LightBlue(object): def find_all_container_repositories( self, published=True, - release_categories=("Generally Available", "Tech Preview", "Beta",)): + release_categories=conf.lightblue_release_categories): """ Returns dict with repository name as key and ContainerRepository as value. @@ -1264,7 +1264,7 @@ class LightBlue(object): def find_images_with_packages_from_content_set( self, srpm_nvrs, content_sets, filter_fnc=None, published=True, - release_categories=("Generally Available", "Tech Preview", "Beta",), + release_categories=conf.lightblue_release_categories, leaf_container_images=None): """Query lightblue and find containers which contain given package from one of content sets @@ -1566,7 +1566,7 @@ class LightBlue(object): def find_images_to_rebuild( self, srpm_nvrs, content_sets, published=True, - release_categories=("Generally Available", "Tech Preview", "Beta",), + release_categories=conf.lightblue_release_categories, filter_fnc=None, leaf_container_images=None): """ Find images to rebuild through image build layers diff --git a/tests/handlers/koji/test_rebuild_images_on_rpm_advisory_change.py b/tests/handlers/koji/test_rebuild_images_on_rpm_advisory_change.py index 147d3e2..eff172d 100644 --- a/tests/handlers/koji/test_rebuild_images_on_rpm_advisory_change.py +++ b/tests/handlers/koji/test_rebuild_images_on_rpm_advisory_change.py @@ -36,6 +36,7 @@ from freshmaker.types import ( ArtifactBuildState, ArtifactType, EventState, RebuildReason) from freshmaker.errata import ErrataAdvisory from freshmaker.config import any_ +from freshmaker import conf from tests import helpers @@ -455,7 +456,7 @@ class TestFindImagesToRebuild(helpers.FreshmakerTestCase): self.find_images_to_rebuild.assert_called_once_with( set(['httpd-2.4-11.el7']), ['content-set-1'], filter_fnc=self.handler._filter_out_not_allowed_builds, - published=True, release_categories=('Generally Available', 'Tech Preview', 'Beta'), + published=True, release_categories=conf.lightblue_release_categories, leaf_container_images=None) @patch.object(freshmaker.conf, 'handler_build_whitelist', new={ @@ -472,7 +473,7 @@ class TestFindImagesToRebuild(helpers.FreshmakerTestCase): self.find_images_to_rebuild.assert_called_once_with( set(['httpd-2.4-11.el7', 'httpd-2.2-11.el6']), ['content-set-1'], filter_fnc=self.handler._filter_out_not_allowed_builds, - published=True, release_categories=('Generally Available', 'Tech Preview', 'Beta'), + published=True, release_categories=conf.lightblue_release_categories, leaf_container_images=None) @patch.object(freshmaker.conf, 'handler_build_whitelist', new={ @@ -508,7 +509,7 @@ class TestFindImagesToRebuild(helpers.FreshmakerTestCase): self.find_images_to_rebuild.assert_called_once_with( set(['httpd-2.4-11.el7']), ['content-set-1'], filter_fnc=self.handler._filter_out_not_allowed_builds, - published=True, release_categories=('Generally Available', 'Tech Preview', 'Beta'), + published=True, release_categories=conf.lightblue_release_categories, leaf_container_images=None) @patch.object(freshmaker.conf, 'handler_build_whitelist', new={ @@ -526,7 +527,7 @@ class TestFindImagesToRebuild(helpers.FreshmakerTestCase): self.find_images_to_rebuild.assert_called_once_with( set(['httpd-2.4-11.el7']), ['content-set-1'], filter_fnc=self.handler._filter_out_not_allowed_builds, - published=True, release_categories=('Generally Available', 'Tech Preview', 'Beta'), + published=True, release_categories=conf.lightblue_release_categories, leaf_container_images=["foo", "bar"]) @patch.object(freshmaker.conf, 'handler_build_whitelist', new={ @@ -549,7 +550,7 @@ class TestFindImagesToRebuild(helpers.FreshmakerTestCase): self.find_images_to_rebuild.assert_called_once_with( set(['httpd-2.4-11.el7']), ['content-set-1'], filter_fnc=self.handler._filter_out_not_allowed_builds, - published=True, release_categories=('Generally Available', 'Tech Preview', 'Beta'), + published=True, release_categories=conf.lightblue_release_categories, leaf_container_images=None)