Esempio n. 1
0
    def _update_build_config_when_exist(self, build_json):
        existing_bc = self._get_existing_build_config(build_json)
        self._verify_labels_match(build_json, existing_bc)
        # Existing build config may have a different name if matched by
        # git-repo-name and git-branch labels. Continue using existing
        # build config name.
        build_config_name = existing_bc['metadata']['name']
        logger.debug('existing build config name to be used "%s"',
                     build_config_name)
        self._verify_no_running_builds(build_config_name)

        # Remove nodeSelector, will be set from build_json for worker build
        old_nodeselector = existing_bc['spec'].pop('nodeSelector', None)
        logger.debug("removing build config's nodeSelector %s", old_nodeselector)

        # Remove koji_task_id
        koji_task_id = utils.graceful_chain_get(existing_bc, 'metadata', 'labels',
                                                'koji-task-id')
        if koji_task_id is not None:
            logger.debug("removing koji-task-id %r", koji_task_id)
            utils.graceful_chain_del(existing_bc, 'metadata', 'labels', 'koji-task-id')

        utils.buildconfig_update(existing_bc, build_json)
        # Reset name change that may have occurred during
        # update above, since renaming is not supported.
        existing_bc['metadata']['name'] = build_config_name
        logger.debug('build config for %s already exists, updating...',
                     build_config_name)

        self.os.update_build_config(build_config_name, json.dumps(existing_bc))
        return existing_bc
    def test_no_repositories(self, workflow, reactor_config_map):  # noqa
        archives = copy.deepcopy(ARCHIVES)
        for archive in archives:
            graceful_chain_del(archive, 'extra', 'docker', 'repositories')

        koji_session(archives=archives)
        with pytest.raises(PluginFailedException) as exc_info:
            self.run_plugin_with_args(workflow, reactor_config_map=reactor_config_map)
        assert 'A suitable archive' in str(exc_info.value)
        assert 'not found' in str(exc_info.value)
    def test_no_repositories(self, workflow):
        archives = copy.deepcopy(ARCHIVES)
        for archive in archives:
            graceful_chain_del(archive, 'extra', 'docker', 'repositories')

        koji_session(archives=archives)
        with pytest.raises(PluginFailedException) as exc_info:
            self.run_plugin_with_args(workflow)
        assert 'A suitable archive' in str(exc_info.value)
        assert 'not found' in str(exc_info.value)
Esempio n. 4
0
    def _prepare_resource(resource_type, resource):
        utils.graceful_chain_del(resource, 'metadata', 'resourceVersion')

        if resource_type == 'buildconfigs':
            utils.graceful_chain_del(resource, 'status', 'lastVersion')

            triggers = utils.graceful_chain_get(resource, 'spec', 'triggers') or ()
            for t in triggers:
                utils.graceful_chain_del(t, 'imageChange', 'lastTrigerredImageID')
Esempio n. 5
0
    def _prepare_resource(resource_type, resource):
        utils.graceful_chain_del(resource, 'metadata', 'resourceVersion')

        if resource_type == 'buildconfigs':
            utils.graceful_chain_del(resource, 'status', 'lastVersion')

            triggers = utils.graceful_chain_get(resource, 'spec', 'triggers') or ()
            for t in triggers:
                utils.graceful_chain_del(t, 'imageChange', 'lastTrigerredImageID')
Esempio n. 6
0
 def _prepare_resource(resource):
     utils.graceful_chain_del(resource, 'metadata', 'resourceVersion')
Esempio n. 7
0
 def _prepare_resource(resource):
     utils.graceful_chain_del(resource, 'metadata', 'resourceVersion')