#553 Fix rpkg container-build ignoring values when same argument is specified multiple times
Merged 3 years ago by onosek. Opened 3 years ago by abisoi.
abisoi/rpkg args-fix  into  master

file modified
+20 -1
@@ -1591,12 +1591,13 @@ 

  

          parser.add_argument(

              '--arches',

-             action='store',

+             action='append',

              nargs='*',

              help='Limit a scratch or a isolated build to an arch. May have multiple arches.')

  

          parser.add_argument(

              '--repo-url',

+             action='append',

              metavar="URL",

              help='URLs of yum repo files',

              nargs='+')
@@ -1630,6 +1631,7 @@ 

  

          self.container_build_parser.add_argument(

              '--compose-id',

+             action='append',

              dest='compose_ids',

              metavar='COMPOSE_ID',

              type=int,
@@ -1637,6 +1639,7 @@ 

              nargs='+')

          self.container_build_parser.add_argument(

              '--replace-dependency',

+             action='append',

              metavar="PKG_MANAGER:NAME:VERSION[:NEW_NAME]",

              help='Cachito dependency replacement',

              nargs='+')
@@ -2035,6 +2038,16 @@ 

              self.cmd._target = self.args.target

              target_override = True

  

+         # Group similar argparse arguments into single list

+         def group_arguments(arg):

+             return sum((item for item in arg), [])

+ 

+         if self.args.repo_url:

+             self.args.repo_url = group_arguments(self.args.repo_url)

+ 

+         if self.args.arches:

+             self.args.arches = group_arguments(self.args.arches)

+ 

          if self.args.release:

              self.log.warning('using --release with container-build will cause git_branch to be '

                               'overridden, and if the specified commit is not present in the '
@@ -2053,6 +2066,12 @@ 

                  "yum_repourls": self.args.repo_url}

  

          if not flatpak:

+             if self.args.compose_ids:

+                 self.args.compose_ids = group_arguments(self.args.compose_ids)

+ 

+             if self.args.replace_dependency:

+                 self.args.replace_dependency = group_arguments(self.args.replace_dependency)

+ 

              if self.args.compose_ids and self.args.signing_intent:

                  raise rpkgError("argument --compose-id: not allowed with argument"

                                  " --signing-intent")

file modified
+65
@@ -229,6 +229,71 @@ 

              flatpak=False

          )

  

+     def test_mutiple_arguments_repo_url(self):

+         cli_cmd = ['rpkg', '--path', self.cloned_repo_path, 'container-build',

+                    '--target', 'f34-container-candidate', '--scratch',

+                    '--repo-url', 'a', 'b', '--repo-url', 'c']

+ 

+         with patch('sys.argv', new=cli_cmd):

+             cli = self.new_cli()

+             cli.container_build_koji()

+ 

+         self.assertEqual('f34-container-candidate', cli.cmd._target)

+         self.mock_container_build_koji.assert_called_once_with(

+             True,

+             opts={

+                 'scratch': True,

+                 'quiet': False,

+                 'release': None,

+                 'isolated': False,

+                 'koji_parent_build': None,

+                 'yum_repourls': ['a', 'b', 'c'],

+                 'dependency_replacements': None,

+                 'git_branch': 'eng-rhel-7',

+                 'arches': None,

+                 'signing_intent': None,

+                 'compose_ids': None,

+                 'skip_build': False

+             },

+             kojiprofile='koji',

+             build_client=utils.build_client,

+             koji_task_watcher=koji_cli.lib.watch_tasks,

+             nowait=False,

+             flatpak=False

+         )

+ 

+     def test_mutiple_arguments_compose_ids(self):

+         cli_cmd = ['rpkg', '--path', self.cloned_repo_path, 'container-build',

+                    '--target', 'f34-container-candidate', '--scratch',

+                    '--compose-id', '1', '2', '--compose-id', '3']

+ 

+         with patch('sys.argv', new=cli_cmd):

+             cli = self.new_cli()

+             cli.container_build_koji()

+ 

+         self.mock_container_build_koji.assert_called_once_with(

+             True,

+             opts={

+                 'scratch': True,

+                 'quiet': False,

+                 'release': None,

+                 'isolated': False,

+                 'koji_parent_build': None,

+                 'yum_repourls': None,

+                 'dependency_replacements': None,

+                 'git_branch': 'eng-rhel-7',

+                 'arches': None,

+                 'signing_intent': None,

+                 'compose_ids': [1, 2, 3],

+                 'skip_build': False

+             },

+             kojiprofile='koji',

+             build_client=utils.build_client,

+             koji_task_watcher=koji_cli.lib.watch_tasks,

+             nowait=False,

+             flatpak=False

+         )

+ 

      def test_isolated(self):

          cli_cmd = ['rpkg', '--path', self.cloned_repo_path, 'container-build',

                     '--isolated', '--build-release', '99']

Presently, in container-build --arg1 X --arg1 Y equals --arg1=Y, which ignores X and any other previous values. This MR accumulates all such values under the common argument.

JIRA: RHELCMP-4112
Resolves: pagure #537

Signed-off-by: Aditya Bisoi abisoi@redhat.com

rebased onto 65f199686e43614213a476456fdcb759451fc468

3 years ago

rebased onto 211f93833e3fa6aebf53e1b0441f79c40d80fdc9

3 years ago

rebased onto 64be4bc8553993ab59eace1fcc9a3387b409e6c0

3 years ago

rebased onto 0768104d663689959c513d775a5c89b8c5569867

3 years ago

rebased onto e30103901be7ca785f5ec0f42d88bbd2e6c3c26b

3 years ago

pretty please pagure-ci rebuild

3 years ago

rebased onto c50c083c4fc1ad74a008eff8dd84863483b053f8

3 years ago

pretty please pagure-ci rebuild

3 years ago

rebased onto ade3df087f83be5d3dc9a1086a56dffa1c007e65

3 years ago

pretty please pagure-ci rebuild

3 years ago

rebased onto d907b7e5503ecd97c534507b92f3f4ae51c8ffb4

3 years ago

rebased onto 26e555979e8a7a07b48ea02fb3c1778f871cd0bc

3 years ago

rebased onto 16bc6cf0d234c63344a8837d3d77f1d7e3b1da15

3 years ago

rebased onto 7c7e2b6

3 years ago

pretty please pagure-ci rebuild

3 years ago

pretty please pagure-ci rebuild

3 years ago

The commit changes the behaviour of some specific arguments for subcommand container-build (and flatpak-build):

  • --arches
  • --repo-url
  • --compose-id (not applicable for flatpak-build)
  • --replace-dependency (not applicable for flatpak-build)

Currently, both approaches (and even their combination) are possible:

  • --arg X Y
  • --arg X --arg Y

Pull-Request has been merged by onosek

3 years ago
Metadata