Add web request options 'scratch' and 'srpms' for module scratch builds.

Signed-off-by: Merlin Mathesius <mmathesi@redhat.com>
This commit is contained in:
Merlin Mathesius
2019-02-07 14:01:35 -06:00
parent fcac146230
commit f2e7a8db07
3 changed files with 38 additions and 7 deletions

View File

@@ -18,7 +18,10 @@ tasks:
Change Log
==========
For a detailed change log, see ``docs/CHANGELOG.rst``.
For a detailed change log, see |docs/CHANGELOG.rst|_.
.. |docs/CHANGELOG.rst| replace:: ``docs/CHANGELOG.rst``
.. _docs/CHANGELOG.rst: docs/CHANGELOG.rst
Supported build systems
=======================
@@ -102,9 +105,13 @@ Options:
``{'platform': ['f28', 'f29']}``.
- ``require_overrides`` - the requires to override the modulemd with. The overrides must be to
existing requires on the modulemd. The expected format is ``{'platform': ['f28', 'f29']}``.
- ``scratch`` - a boolean indicating if a scratch module build should be performed.
Only allowed to be ``True`` if the MBS setting ``MODULE_ALLOW_SCRATCH`` is ``True``.
- ``yaml`` - a string of the input file when submitting a YAML file directly in a
``multipart/form-data`` request. The MBS setting ``YAML_SUBMIT_ALLOWED`` must be set to ``True``
for this to be allowed.
- ``srpms`` - an optional list of Koji upload URLs of SRPMs to include in a module scratch build.
Only allowed if ``scratch`` is ``True``.
- ``rebuild_strategy`` - a string of the desired rebuild strategy (affects what components get
rebuilt). For the available options, please look at the "Rebuild Strategies" section below.
@@ -239,8 +246,8 @@ The response includes:
- ``owner`` - the username of the owner or person who submitted the module build.
- ``scmurl`` - the source control URL used to build the module.
- ``state`` - the numerical state of the module build.
- ``state_name`` - the named state of the module build. See the section called.
"Module Build States" for more information.
- ``state_name`` - the named state of the module build. See the section called
`Module Build States`_ for more information.
- ``state_reason`` - the reason why the module build is in this state. This is useful
when the build fails.
- ``stream`` - the module's stream.
@@ -925,7 +932,10 @@ the following rules (all of them are evaluated from top to bottom):
TestConfiguration is used, otherwise...
- if ``MODULE_BUILD_SERVICE_DEVELOPER_ENV`` is set to some reasonable
value, DevConfiguration is forced and ``config.py`` is used directly from the
MBS's develop instance. For more information see ``docs/CONTRIBUTING.rst``.
MBS's develop instance. For more information see |docs/CONTRIBUTING.rst|_.
.. |docs/CONTRIBUTING.rst| replace:: ``docs/CONTRIBUTING.rst``
.. _docs/CONTRIBUTING.rst: docs/CONTRIBUTING.rst
Setting Up Kerberos + LDAP Authentication
@@ -954,12 +964,15 @@ must be set in ``/etc/module-build-service/config.py``:
Development
===========
For help on setting up a development environment, see ``docs/CONTRIBUTING.rst``.
For help on setting up a development environment, see |docs/CONTRIBUTING.rst|_.
License
=======
MBS is licensed under MIT license. See LICENSE file for details.
MBS is licensed under MIT license. See |LICENSE|_ file for details.
.. |LICENSE| replace:: ``LICENSE``
.. _LICENSE: LICENSE
Parts of MBS are licensed under 3-clause BSD license from:
https://github.com/projectatomic/atomic-reactor/blob/master/LICENSE

View File

@@ -57,6 +57,7 @@ class BaseConfiguration(object):
MODULES_DEFAULT_REPOSITORY = 'https://src.fedoraproject.org/modules/'
MODULES_ALLOW_REPOSITORY = False
MODULES_ALLOW_SCRATCH = False
ALLOWED_GROUPS = set([
'packager',

View File

@@ -37,7 +37,7 @@ from module_build_service.utils import (
pagination_metadata, filter_module_builds, filter_component_builds,
submit_module_build_from_scm, submit_module_build_from_yaml,
get_scm_url_re, cors_header, validate_api_version, import_mmd,
get_mmd_from_scm)
get_mmd_from_scm, str_to_bool)
from module_build_service.errors import (
ValidationError, Forbidden, NotFound, ProgrammingError)
from module_build_service.backports import jsonify
@@ -323,6 +323,23 @@ class BaseHandler(object):
log.error('Invalid JSON submitted')
raise ValidationError('Invalid JSON submitted')
# canonicalize and validate scratch option
if 'scratch' in self.data and str_to_bool(str(self.data['scratch'])):
self.data['scratch'] = True
if conf.modules_allow_scratch is not True:
raise Forbidden('Scratch builds are not enabled')
else:
self.data['scratch'] = False
# canonicalize and validate srpms list
if 'srpms' in self.data and self.data['srpms']:
if not self.data['scratch']:
raise Forbidden('srpms may only be specified for scratch builds')
if not isinstance(self.data['srpms'], list):
raise ValidationError('srpms must be specified as a list')
else:
self.data['srpms'] = []
@property
def optional_params(self):
return {k: v for k, v in self.data.items() if k not in ["owner", "scmurl", "branch"]}