mirror of
https://pagure.io/fm-orchestrator.git
synced 2026-12-01 08:45:48 +08:00
Create method for loading modulemd object from yaml
This commit is contained in:
@@ -287,12 +287,7 @@ def _fetch_mmd(url, allow_local_url = False):
|
||||
"Failed to remove temporary directory {!r}: {}".format(
|
||||
td, str(e)))
|
||||
|
||||
mmd = modulemd.ModuleMetadata()
|
||||
try:
|
||||
mmd.loads(yaml)
|
||||
except Exception as e:
|
||||
log.error('Invalid modulemd: %s' % str(e))
|
||||
raise UnprocessableEntity('Invalid modulemd: %s' % str(e))
|
||||
mmd = load_mmd(yaml)
|
||||
|
||||
# If undefined, set the name field to VCS repo name.
|
||||
if not mmd.name and scm:
|
||||
@@ -308,6 +303,17 @@ def _fetch_mmd(url, allow_local_url = False):
|
||||
|
||||
return mmd, scm, yaml
|
||||
|
||||
|
||||
def load_mmd(yaml):
|
||||
mmd = modulemd.ModuleMetadata()
|
||||
try:
|
||||
mmd.loads(yaml)
|
||||
except Exception as e:
|
||||
log.error('Invalid modulemd: %s' % str(e))
|
||||
raise UnprocessableEntity('Invalid modulemd: %s' % str(e))
|
||||
return mmd
|
||||
|
||||
|
||||
def _scm_get_latest(pkg):
|
||||
try:
|
||||
# If the modulemd specifies that the 'f25' branch is what
|
||||
|
||||
Reference in New Issue
Block a user