| |
@@ -1,4 +1,5 @@
|
| |
# Copyright © 2019 Red Hat, Inc.
|
| |
+ # Copyright © 2019 Igor Gnatenko
|
| |
#
|
| |
# SPDX-License-Identifier: GPL-2.0-or-later
|
| |
|
| |
@@ -18,14 +19,55 @@
|
| |
get_build_target,
|
| |
_create_tag,
|
| |
_create_build_target,
|
| |
+ _edit_tag,
|
| |
_delete_tag,
|
| |
_delete_build_target,
|
| |
+ editTag2 as editTag,
|
| |
readTaggedBuilds,
|
| |
QueryProcessor,
|
| |
nextval,
|
| |
)
|
| |
|
| |
|
| |
+ def _is_plugin_extra(key):
|
| |
+ return key == "sidetag" or key.startswith("sidetag_")
|
| |
+
|
| |
+
|
| |
+ @export
|
| |
+ def editTag2(tagInfo, **kwargs):
|
| |
+ """Edit information for an existing tag.
|
| |
+
|
| |
+ For the side tags where user is an owner, allow modifications
|
| |
+ as long as user does not change name or sidetag settings.
|
| |
+
|
| |
+ This function overrides hub function.
|
| |
+ """
|
| |
+ context.session.assertLogin()
|
| |
+ user = get_user(context.session.user_id, strict=True)
|
| |
+ tag = get_tag(tagInfo, strict=True)
|
| |
+
|
| |
+ if (
|
| |
+ tag["extra"].get("sidetag")
|
| |
+ and tag["extra"].get("sidetag_user_id") == user["id"]
|
| |
+ ):
|
| |
+ if "name" in kwargs and kwargs["name"] != tag["name"]:
|
| |
+ raise koji.GenericError("Change of the tag name is not allowed")
|
| |
+ for key, value in kwargs.get("extra", {}).items():
|
| |
+ if _is_plugin_extra(key) and (
|
| |
+ key not in tag["extra"] or value != tag["extra"][key]
|
| |
+ ):
|
| |
+ raise koji.GenericError(
|
| |
+ "Addition or modification of sidetag settings is not allowed"
|
| |
+ )
|
| |
+ for key in kwargs.get("remove_extra", []):
|
| |
+ if _is_plugin_extra(key) and key in tag["extra"]:
|
| |
+ raise koji.GenericError("Removal of sidetag settings is not allowed")
|
| |
+ edit_func = _edit_tag
|
| |
+ else:
|
| |
+ edit_func = editTag
|
| |
+ edit_func(tagInfo, **kwargs)
|
| |
+
|
| |
+
|
| |
@export
|
| |
def createSideTag(basetag):
|
| |
"""Create a side tag.
|
| |
cc @tkopecek