From 1f37c646f766b71f8bfd9305b46262416c889d88 Mon Sep 17 00:00:00 2001 From: Mike McLean Date: May 06 2021 16:05:07 +0000 Subject: add allow_dashes_in_svc config option --- diff --git a/module_build_service/common/config.py b/module_build_service/common/config.py index 35f22b0..91bbb33 100644 --- a/module_build_service/common/config.py +++ b/module_build_service/common/config.py @@ -754,6 +754,11 @@ class Config(object): ], "desc": "The list Python paths for the Celery application to import.", }, + "allow_dashes_in_svc": { + "type": bool, + "default": False, + "desc": "Whether to allow dashes in stream, version, and context values.", + }, } def __init__(self, conf_section_obj): diff --git a/module_build_service/common/submit.py b/module_build_service/common/submit.py index c93338c..b0cf72e 100644 --- a/module_build_service/common/submit.py +++ b/module_build_service/common/submit.py @@ -84,11 +84,18 @@ def fetch_mmd(url, branch=None, allow_local_url=False, whitelist_url=False, mand # If the stream was set in the modulemd, make sure it matches what the repo # branch is - if stream_or_packager.get_stream_name() and stream_or_packager.get_stream_name() != scm.branch: + stream_override = stream_or_packager.get_stream_name() + scm_stream = scm.branch + if not conf.allow_dashes_in_svc: + scm_stream = scm_stream.replace('-', '_') + if stream_override and '-' in stream_override: + raise ValidationError('Dashes are not allowed in the stream value') + if stream_override and stream_override != scm_stream: if not conf.allow_stream_override_from_scm: raise ValidationError( - 'The stream "{0}" that is stored in the modulemd does not match the branch "{1}"' - .format(stream_or_packager.get_stream_name(), scm.branch) + 'The stream "{0}" that is stored in the modulemd does not match the stream ' + 'determined by the branch "{1}"' + .format(stream_override, scm_stream) ) else: # Set the module stream