#925 Allow longer Build Target names
Merged 3 years ago by mikem. Opened 4 years ago by mprahl.
Unknown source target-length  into  master

@@ -0,0 +1,10 @@

+ -- upgrade script to migrate the Koji database schema

+ -- from version 1.16 to 1.17

+ 

+ 

+ BEGIN;

+ 

+ -- Change VARCHAR field for build_target names to TEXT to allow longer names

+ ALTER TABLE build_target ALTER COLUMN name TYPE TEXT;

+ 

+ COMMIT;

file modified
+1 -1
@@ -408,7 +408,7 @@

  -- and how to tag it afterwards.

  CREATE TABLE build_target (

  	id SERIAL NOT NULL PRIMARY KEY,

- 	name VARCHAR(50) UNIQUE NOT NULL

+ 	name TEXT UNIQUE NOT NULL

  ) WITHOUT OIDS;

  

  

file modified
+9
@@ -2669,10 +2669,18 @@

      insert = InsertProcessor('tag_updates', data=data)

      insert.execute()

  

+ def _validate_build_target_name(name):

+     """ A helper function that validates a build target name. """

+     max_name_length = 256

+     if len(name) > max_name_length:

+         raise koji.GenericError("Build target name %s is too long. Max length "

+                                 "is %s characters" % (name, max_name_length))

+ 

  def create_build_target(name, build_tag, dest_tag):

      """Create a new build target"""

  

      context.session.assertPerm('admin')

+     _validate_build_target_name(name)

  

      # Does a target with this name already exist?

      if get_build_targets(info=name):
@@ -2702,6 +2710,7 @@

  def edit_build_target(buildTargetInfo, name, build_tag, dest_tag):

      """Set the build_tag and dest_tag of an existing build_target to new values"""

      context.session.assertPerm('admin')

+     _validate_build_target_name(name)

  

      target = lookup_build_target(buildTargetInfo)

      if not target:

The tag name length restriction was increased to 256 characters last year [1]. Because of this, MBS started using more informative tag names [2] but it turns out that the tag name is also used to create the build target. We'd like to keep the naming consistent and to do this, we must increases the length restriction on build target names.

1 - https://pagure.io/koji/c/d9280d694501afb2df6c12b3f9778beb73f350a0?branch=master
2 - https://pagure.io/fm-orchestrator/issue/918

rebased onto c6b9cebf94b5590315d982a217a5adc109dd0ad9

4 years ago

Name is used in more places (edit_build_target), which needs to check this length also.

rebased onto 4fa12c52f71d4dcc226a59e306fbcf047d0b41d7

4 years ago

@tkopecek I just added the length check to edit_build_target. Are there any other locations that you're aware of?

rebased onto 94fb84ee2d02de63bef1155890d6ab928ca444ec

4 years ago

rebased onto b7fc842

4 years ago

I believe, this is all.
:thumbsup:

Commit 54b8c36 fixes this pull-request

Pull-Request has been merged by mikem

3 years ago