Пример #1
0
    def test_checks_out_repo(self, local_fake_repo, add_git_suffix):
        if add_git_suffix:
            repo_url = local_fake_repo + ".git"
            os.rename(local_fake_repo, repo_url)
        else:
            repo_url = local_fake_repo
        gs = GitSource('git', repo_url)
        gs.get()
        assert os.path.exists(os.path.join(gs.path, '.git'))
        assert os.path.basename(gs.path) == 'app-operator'

        assert len(gs.commit_id) == 40  # current git hashes are this long
Пример #2
0
    def test_checks_out_repo(self, local_fake_repo, add_git_suffix):
        if add_git_suffix:
            repo_url = local_fake_repo + ".git"
            os.rename(local_fake_repo, repo_url)
        else:
            repo_url = local_fake_repo
        gs = GitSource('git', repo_url)
        gs.get()
        assert os.path.exists(os.path.join(gs.path, '.git'))
        assert os.path.basename(gs.path) == 'app-operator'
        assert gs.commit_id is not None
        assert len(gs.commit_id) == 40  # current git hashes are this long

        previous_commit_id = gs.commit_id
        gs.reset('HEAD~2')  # Go back two commits
        assert gs.commit_id is not None
        assert gs.commit_id != previous_commit_id
        assert len(gs.commit_id) == 40  # current git hashes are this long
Пример #3
0
    def check_lookaside_cache_usage(self):
        """Check usage of lookaside cache, and fail if used"""
        git_uri, git_commit = self.koji_build['source'].split('#')

        source = GitSource('git', git_uri, provider_params={'git_commit': git_commit})
        source_path = source.get()
        sources_cache_file = os.path.join(source_path, 'sources')

        if os.path.exists(sources_cache_file):
            if os.path.getsize(sources_cache_file) > 0:
                raise RuntimeError('Repository is using lookaside cache, which is not allowed '
                                   'for source container builds')
        source.remove_tmpdir()
Пример #4
0
    def check_lookaside_cache_usage(self):
        """Check usage of lookaside cache, and fail if used"""
        git_uri, git_commit = self.koji_build['source'].split('#')

        source = GitSource('git',
                           git_uri,
                           provider_params={'git_commit': git_commit})
        source_path = source.get()
        sources_cache_file = os.path.join(source_path, 'sources')

        uses_cache = False
        if os.path.exists(sources_cache_file):
            if os.path.getsize(sources_cache_file) > 0:
                uses_cache = True

        source.remove_workdir()

        if not uses_cache:
            return

        allowlist_cache_yaml = self._get_cache_allowlist()
        should_raise = True

        if allowlist_cache_yaml:
            build_component = self.koji_build['package_name']
            build_task = self.koji_build['extra']['container_koji_task_id']
            task_info = self.session.getTaskInfo(build_task, request=True)
            build_target = task_info['request'][1]

            for allowed in allowlist_cache_yaml:
                if allowed['component'] != build_component:
                    continue

                for target in allowed['targets']:
                    if re.match(target, build_target):
                        self.log.debug(
                            'target "%s" for component "%s" has allowed using '
                            'lookaside cache', build_target, build_component)

                        should_raise = False
                        break

                if not should_raise:
                    break

        if should_raise:
            raise RuntimeError(
                'Repository is using lookaside cache, which is not allowed '
                'for source container builds')