show/edit tag extra options in cli
This commit is contained in:
parent
a0285163b5
commit
9c8832f3c1
2 changed files with 45 additions and 11 deletions
15
cli/koji
15
cli/koji
|
|
@ -4353,6 +4353,12 @@ def anon_handle_taginfo(options, session, args):
|
|||
if session.mavenEnabled():
|
||||
print "Maven support?: %s" % (info['maven_support'] and 'yes' or 'no')
|
||||
print "Include all Maven archives?: %s" % (info['maven_include_all'] and 'yes' or 'no')
|
||||
if 'extra' in info:
|
||||
print "Tag options:"
|
||||
keys = info['extra'].keys()
|
||||
keys.sort()
|
||||
for key in keys:
|
||||
print " %s : %s" % (key, pprint.pformat(info['extra'][key]))
|
||||
dest_targets = session.getBuildTargets(destTagID=info['id'], **event_opts)
|
||||
build_targets = session.getBuildTargets(buildTagID=info['id'], **event_opts)
|
||||
repos = {}
|
||||
|
|
@ -4446,6 +4452,8 @@ def handle_edit_tag(options, session, args):
|
|||
parser.add_option("--no-maven-support", action="store_true", help=_("Disable creation of Maven repos for this tag"))
|
||||
parser.add_option("--include-all", action="store_true", help=_("Include all packages in this tag when generating Maven repos"))
|
||||
parser.add_option("--no-include-all", action="store_true", help=_("Do not include all packages in this tag when generating Maven repos"))
|
||||
parser.add_option("-x", "--extra", action="append", default=[], metavar="key=value",
|
||||
help=_("Set tag extra option"))
|
||||
(options, args) = parser.parse_args(args)
|
||||
if len(args) != 1:
|
||||
parser.error(_("Please specify a name for the tag"))
|
||||
|
|
@ -4473,6 +4481,13 @@ def handle_edit_tag(options, session, args):
|
|||
opts['maven_include_all'] = True
|
||||
if options.no_include_all:
|
||||
opts['maven_include_all'] = False
|
||||
if options.extra:
|
||||
extra = {}
|
||||
for xopt in options.extra:
|
||||
key, value = xopt.split('=')
|
||||
value = arg_filter(value)
|
||||
extra[key] = value
|
||||
opts['extra'] = extra
|
||||
#XXX change callname
|
||||
session.editTag2(tag,**opts)
|
||||
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ import os
|
|||
import re
|
||||
import rpm
|
||||
import shutil
|
||||
import simplejson as json
|
||||
import stat
|
||||
import subprocess
|
||||
import sys
|
||||
|
|
@ -2822,7 +2823,7 @@ def get_tag_extra(tagInfo, event=None):
|
|||
result = {}
|
||||
for key, value in query.execute():
|
||||
try:
|
||||
value = simplejson.loads(value)
|
||||
value = json.loads(value)
|
||||
except Exception:
|
||||
# this should not happen
|
||||
raise koji.GenericError("Invalid tag extra data: %s : %r", key, value)
|
||||
|
|
@ -2885,18 +2886,36 @@ def edit_tag(tagInfo, **kwargs):
|
|||
if kwargs.has_key(key) and data[key] != kwargs[key]:
|
||||
changed = True
|
||||
data[key] = kwargs[key]
|
||||
if not changed:
|
||||
return
|
||||
if changed:
|
||||
update = UpdateProcessor('tag_config', values=data, clauses=['tag_id = %(id)i'])
|
||||
update.make_revoke()
|
||||
update.execute()
|
||||
|
||||
update = UpdateProcessor('tag_config', values=data, clauses=['tag_id = %(id)i'])
|
||||
update.make_revoke()
|
||||
update.execute()
|
||||
insert = InsertProcessor('tag_config', data=dslice(data, ('arches', 'perm_id', 'locked')))
|
||||
insert.set(tag_id=data['id'])
|
||||
insert.set(**dslice(data, ('maven_support', 'maven_include_all')))
|
||||
insert.make_create()
|
||||
insert.execute()
|
||||
|
||||
# handle extra data
|
||||
if 'extra' in kwargs:
|
||||
for key in kwargs['extra']:
|
||||
value = kwargs['extra'][key]
|
||||
if key not in tag['extra'] or tag['extra'] != value:
|
||||
data = {
|
||||
'tag_id' : tag['id'],
|
||||
'key' : key,
|
||||
'value' : json.dumps(kwargs['extra'][key]),
|
||||
}
|
||||
# revoke old entry, if any
|
||||
update = UpdateProcessor('tag_extra', values=data, clauses=['tag_id = %(tag_id)i', 'key=%(key)s'])
|
||||
update.make_revoke()
|
||||
update.execute()
|
||||
# add new entry
|
||||
insert = InsertProcessor('tag_extra', data=data)
|
||||
insert.make_create()
|
||||
insert.execute()
|
||||
|
||||
insert = InsertProcessor('tag_config', data=dslice(data, ('arches', 'perm_id', 'locked')))
|
||||
insert.set(tag_id=data['id'])
|
||||
insert.set(**dslice(data, ('maven_support', 'maven_include_all')))
|
||||
insert.make_create()
|
||||
insert.execute()
|
||||
|
||||
def old_edit_tag(tagInfo, name, arches, locked, permissionID):
|
||||
"""Edit information for an existing tag."""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue