#2730 configurable sidetags suffixes
Merged a year ago by tkopecek. Opened a year ago by tkopecek.
tkopecek/koji issue2729  into  master

file modified
+12 -1
@@ -33,15 +33,26 @@ 

      parser.add_argument(

          "--debuginfo", action="store_true", help=_("Buildroot repo will contain debuginfos")

      )

+     parser.add_argument(

+         "--suffix", actions="store", help=_("Suffix from hub-supported ones")

+     )

  

      opts = parser.parse_args(args)

  

      activate_session(session, options)

  

+     kwargs = {"debuginfo": opts.debuginfo}

+     if opts.suffix:

+         kwargs['suffix'] = opts.suffix

      try:

-         tag = session.createSideTag(opts.basetag, debuginfo=opts.debuginfo)

+         tag = session.createSideTag(opts.basetag, **kwargs)

      except koji.ActionNotAllowed:

          parser.error(_("Policy violation"))

+     except koji.ParameterError as ex:

+         if 'suffix' in str(ex):

+             parser.error(_("Hub is older and doesn't support --suffix, please run it without it"))

+         else:

+             raise

  

      if not opts.quiet:

          print(tag["name"])

@@ -1,3 +1,5 @@ 

  [sidetag]

  # automatically remove sidetag on untagging last package

  remove_empty = off

+ # potential suffixes for sidetag names

+ # allowed_suffixes =

file modified
+15 -1
@@ -26,6 +26,7 @@ 

  

  CONFIG_FILE = "/etc/koji-hub/plugins/sidetag.conf"

  CONFIG = None

+ ALLOWED_SUFFIXES = []

  

  

  def is_sidetag(taginfo, raise_error=False):
@@ -70,7 +71,7 @@ 

  

  # API calls

  @export

- def createSideTag(basetag, debuginfo=False):

+ def createSideTag(basetag, debuginfo=False, suffix=None):

      """Create a side tag.

  

      :param basetag: name or ID of base tag
@@ -78,8 +79,17 @@ 

  

      :param debuginfo: should buildroot repos contain debuginfo?

      :type debuginfo: bool

+ 

+     :param suffix: suffix which will be appended to generated sidetag name

+                    List of allowed suffixes needs to be defined in config.

+     :type suffix: str

+ 

+     :returns dict: sidetag name + id

      """

  

+     if suffix and suffix not in ALLOWED_SUFFIXES:

+         raise koji.GenericError("%s suffix is not allowed for sidetag" % suffix)

+ 

      # Any logged-in user is able to request creation of side tags,

      # as long the request meets the policy.

      context.session.assertLogin()
@@ -109,6 +119,8 @@ 

      # id assigned by _create_tag

      tag_id = nextval("tag_id_seq") + 1

      sidetag_name = "%s-side-%s" % (basetag["name"], tag_id)

+     if suffix:

+         sidetag_name += '-%s' % suffix

      extra = {

          "sidetag": True,

          "sidetag_user": user["name"],
@@ -306,3 +318,5 @@ 

          "sidetag", "remove_empty"

      ):

          handle_sidetag_untag = callback("postUntag")(handle_sidetag_untag)

+     if CONFIG.has_option("sidetag", "allowed_suffixes"):

+         ALLOWED_SUFFIXES = CONFIG.get("sidetag", "allowed_suffixes").split(',')

Metadata Update from @tkopecek:
- Pull-request tagged with: testing-ready

a year ago

pretty please pagure-ci rebuild

a year ago

Commit f3854d9 fixes this pull-request

Pull-Request has been merged by tkopecek

a year ago

Metadata Update from @jcupova:
- Pull-request tagged with: testing-done

a year ago