From 6e12e6c4eb3f3e4011d2cdc4a12ffe0747c65d34 Mon Sep 17 00:00:00 2001 From: Lubomír Sedlář Date: Sep 20 2017 13:12:16 +0000 Subject: Merge #246 `Remove unsupported osbs for container-build` --- diff --git a/etc/bash_completion.d/rpkg.bash b/etc/bash_completion.d/rpkg.bash index 8a14b40..056fd3a 100644 --- a/etc/bash_completion.d/rpkg.bash +++ b/etc/bash_completion.d/rpkg.bash @@ -124,6 +124,7 @@ _rpkg() options="--scratch --nowait" options_target="--target" options_string="--repo-url" + options_arches="--arches" ;; container-build-config) options="--get-autorebuild" diff --git a/pyrpkg/__init__.py b/pyrpkg/__init__.py index 776ac65..f5e9c6a 100644 --- a/pyrpkg/__init__.py +++ b/pyrpkg/__init__.py @@ -2547,69 +2547,6 @@ class Commands(object): # Run the command self._run_command(cmd, shell=True) - def osbs_build(self, config_file, config_section, target_override=False, - yum_repourls=[], nowait=False, platforms=None): - # Because docker image should be built via Koji not in OSBS directly, - # it is not necessary to make osbs as a hard dependency - try: - from osbs.api import OSBS - from osbs.conf import Configuration - except ImportError: - raise rpkgError('Before building docker image in OSBS directly, ' - 'please install python-osbs-client in advance.') - - self.check_repo() - os_conf = Configuration(conf_file=config_file, conf_section=config_section) - build_conf = Configuration(conf_file=config_file, conf_section=config_section) - osbs = OSBS(os_conf, build_conf) - - git_uri = re.sub(r"^git\+ssh", "git", self.push_url) - git_uri = re.sub("^ssh", "git", git_uri) - git_uri = re.sub("[^/]+@", "", git_uri) - git_ref = self.commithash - git_branch = self.branch_merge - user = self.user - component = self.module_name - container_target = self.target if target_override else self.container_build_target - - if platforms: - architecture = None - else: - architecture = 'x86_64' - build = osbs.create_build( - git_uri=git_uri, - git_ref=git_ref, - git_branch=git_branch, - user=user, - component=component, - target=container_target, - platforms=platforms, - architecture=architecture, - yum_repourls=yum_repourls - ) - build_id = build.build_id - - if nowait: - self.log.info('Build submitted: %s', build_id) - return - - print("Build submitted (%s), watching logs (feel free to interrupt)" % build_id) - for line in osbs.get_build_logs(build_id, follow=True): - print(line) - build_response = osbs.wait_for_build_to_finish(build_id) - if build_response.is_succeeded(): - repositories = build_response.get_repositories() - if repositories: - image_names = repositories.get("primary", []) + repositories.get("unique", []) - print("You can pull the image with one of the following commands:") - for image in image_names: - print(" docker pull %s" % image) - else: - raise RuntimeError( - "Build '%s' wasn't processed correctly. Please, report this." % build_id) - else: - raise RuntimeError("Build has failed.") - def container_build_koji(self, target_override=False, opts={}, kojiconfig=None, kojiprofile=None, build_client=None, diff --git a/pyrpkg/cli.py b/pyrpkg/cli.py index 71f9bdf..80e8b91 100644 --- a/pyrpkg/cli.py +++ b/pyrpkg/cli.py @@ -28,8 +28,6 @@ import six from pyrpkg import rpkgError, log as rpkgLogger from six.moves import xmlrpc_client, configparser -OSBS_DEFAULT_CONF_FILE = "/etc/osbs/osbs.conf" - def warning_deprecated_dist(value): """Warning deprecated of option dist""" @@ -931,42 +929,33 @@ see API KEY section of copr-cli(1) man page. verrel_parser.set_defaults(command=self.verrel) def register_container_build(self): - self.container_build_parser = \ - self.subparsers.add_parser('container-build', - help='build a container') - self.container_build_parser.add_argument('--repo-url', - metavar="URL", - help=("URL of yum repo file"), - nargs='*') - osbs_group = self.container_build_parser.add_argument_group('osbs') - osbs_group.add_argument('--osbs-config', - help="path to file with configuration of osbs", - metavar="PATH", - default=OSBS_DEFAULT_CONF_FILE) - osbs_group.add_argument('--instance', - help=("use specific instance specified " - "by section name in config"), - metavar="SECTION", default="default") - koji_group = self.container_build_parser.add_argument_group('koji') - koji_group.add_argument('--scratch', - help='Scratch build', - action="store_true") + self.container_build_parser = self.subparsers.add_parser( + 'container-build', + help='Build a container', + description='Build a container') + + self.container_build_parser.add_argument( + '--repo-url', + metavar="URL", + help=('URL of yum repo file'), + nargs='*') self.container_build_parser.add_argument( '--target', help='Override the default target', default=None) - self.container_build_parser.add_argument( - '--build-with', - help='Build container with specified builder type. Default is koji', - dest="build_with", - choices=("koji", "osbs"), - default="koji") + self.container_build_parser.add_argument( '--nowait', action='store_true', default=False, help="Don't wait on build") + + self.container_build_parser.add_argument( + '--scratch', + help='Scratch build', + action="store_true") + self.container_build_parser.add_argument( '--arches', action='store', @@ -1181,13 +1170,11 @@ see API KEY section of copr-cli(1) man page. self.cmd.compile(arch=arch, short=short, builddir=self.args.builddir, nocheck=nocheck) - def container_build(self): - if self.args.build_with == "koji": - self.container_build_koji() - elif self.args.build_with == "osbs": - self.container_build_osbs() - def container_build_koji(self): + # Keep it around for backward compatibility + self.container_build() + + def container_build(self): target_override = False # Override the target if we were supplied one if self.args.target: @@ -1236,22 +1223,6 @@ see API KEY section of copr-cli(1) man page. koji_task_watcher=self._watch_koji_tasks, nowait=self.args.nowait) - def container_build_osbs(self): - target_override = False - # Override the target if we were supplied one - if self.args.target: - self.cmd._target = self.args.target - target_override = True - - self.cmd.osbs_build( - config_file=self.args.osbs_config, - config_section=self.args.instance, - target_override=target_override, - yum_repourls=self.args.repo_url, - nowait=self.args.nowait, - platform=self.args.arches - ) - def container_build_setup(self): self.cmd.container_build_setup(get_autorebuild=self.args.get_autorebuild, set_autorebuild=self.args.set_autorebuild) diff --git a/tests/test_cli.py b/tests/test_cli.py index e9a5829..7594739 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -169,7 +169,7 @@ class TestContainerBuildWithKoji(CliTestCase): @patch('pyrpkg.Commands.container_build_koji') def test_using_kojiprofile(self, container_build_koji): cli_cmd = ['rpkg', '--path', self.cloned_repo_path, - 'container-build', '--build-with', 'koji'] + 'container-build'] with patch('sys.argv', new=cli_cmd): cli = self.new_cli() @@ -194,7 +194,7 @@ class TestContainerBuildWithKoji(CliTestCase): @patch('pyrpkg.Commands.container_build_koji') def test_override_target(self, container_build_koji): cli_cmd = ['rpkg', '--path', self.cloned_repo_path, 'container-build', - '--target', 'f25-docker-candidate', '--build-with', 'koji'] + '--target', 'f25-docker-candidate'] with patch('sys.argv', new=cli_cmd): cli = self.new_cli() @@ -226,7 +226,7 @@ class TestContainerBuildWithKoji(CliTestCase): """ cli_cmd = ['rpkg', '--path', self.cloned_repo_path, '--module-name', 'mycontainer', - 'container-build', '--build-with', 'koji'] + 'container-build'] cfg_file = os.path.join(os.path.dirname(__file__), 'fixtures',