Add the ability to specify custom metadata on an RPM build
This adds the `--custom-user-metadata` option to the CLI `build` command. This is then stored under the "extra.custom_user_metadata" field on the resulting build. Signed-off-by: mprahl <mprahl@redhat.com>
This commit is contained in:
parent
b6b7d644b5
commit
cd1b928a5f
3 changed files with 182 additions and 10 deletions
|
|
@ -27,6 +27,7 @@ import copy
|
|||
import glob
|
||||
import grp
|
||||
import io
|
||||
import json
|
||||
import logging
|
||||
import logging.handlers
|
||||
import os
|
||||
|
|
@ -962,6 +963,18 @@ class BuildTask(BaseTaskHandler):
|
|||
repo_info = None
|
||||
# we'll wait for a repo later (self.getRepo)
|
||||
self.event_id = None
|
||||
|
||||
if opts.get('custom_user_metadata'):
|
||||
if not isinstance(opts['custom_user_metadata'], dict):
|
||||
raise koji.BuildError('custom_user_metadata must be serializable to a JSON object')
|
||||
|
||||
try:
|
||||
json.dumps(opts['custom_user_metadata'])
|
||||
except TypeError:
|
||||
error_msg = 'custom_user_metadata is not JSON serializable'
|
||||
self.logger.exception(error_msg)
|
||||
raise koji.BuildError(error_msg)
|
||||
|
||||
task_info = self.session.getTaskInfo(self.id)
|
||||
target_info = None
|
||||
if target:
|
||||
|
|
@ -1019,6 +1032,10 @@ class BuildTask(BaseTaskHandler):
|
|||
data['source'] = self.source['source']
|
||||
data['extra'] = {'source': {'original_url': self.source['url']}}
|
||||
|
||||
if opts.get('custom_user_metadata'):
|
||||
data.setdefault('extra', {})
|
||||
data['extra']['custom_user_metadata'] = opts['custom_user_metadata']
|
||||
|
||||
extra_arches = None
|
||||
self.logger.info("Reading package config for %(name)s" % data)
|
||||
pkg_cfg = self.session.getPackageConfig(dest_tag, data['name'], event=self.event_id)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue