Exemple #1
0
    def test_git_clone_bad_url(self):
        url = 'http://github.com/dummy/armada'
        error_re = '%s is not a valid git repository.' % url

        with self.assertRaisesRegexp(source_exceptions.GitLocationException,
                                     error_re):
            source.git_clone(url)
Exemple #2
0
    def test_git_clone_empty_url(self):
        url = ''
        error_re = '%s is not a valid git repository.' % url

        with self.assertRaisesRegexp(source_exceptions.GitLocationException,
                                     error_re):
            source.git_clone(url)
Exemple #3
0
    def test_git_clone_good_url(self, mock_pygit, mock_temp):
        mock_temp.mkdtemp.return_value = '/tmp/armada'
        mock_pygit.clone_repository.return_value = "Repository"
        url = 'http://github.com/att-comdev/armada'
        dir = source.git_clone(url)

        self.assertIsNotNone(dir)
Exemple #4
0
    def tag_cloned_repo(self, ch, repos):
        location = ch.get('chart').get('source').get('location')
        ct_type = ch.get('chart').get('source').get('type')
        subpath = ch.get('chart').get('source').get('subpath', '.')

        if ct_type == 'local':
            ch.get('chart')['source_dir'] = (location, subpath)
        elif ct_type == 'tar':
            LOG.info('Downloading tarball from: %s', location)
            tarball_dir = source.get_tarball(location)
            ch.get('chart')['source_dir'] = (tarball_dir, subpath)
        elif ct_type == 'git':
            reference = ch.get('chart').get('source').get(
                'reference', 'master')
            repo_branch = (location, reference)

            if repo_branch not in repos:
                try:
                    LOG.info('Cloning repo: %s branch: %s', *repo_branch)
                    repo_dir = source.git_clone(*repo_branch)
                except Exception:
                    raise source_exceptions.GitLocationException(
                        '{} reference: {}'.format(*repo_branch))
                repos[repo_branch] = repo_dir
                ch.get('chart')['source_dir'] = (repo_dir, subpath)
            else:
                ch.get('chart')['source_dir'] = (repos.get(repo_branch),
                                                 subpath)
        else:
            chart_name = ch.get('chart').get('chart_name')
            raise source_exceptions.ChartSourceException(ct_type, chart_name)
Exemple #5
0
    def _get_chart(self, ch):
        chart = ch.get(const.KEYWORD_DATA)
        chart_source = chart.get('source', {})
        location = chart_source.get('location')
        ct_type = chart_source.get('type')
        subpath = chart_source.get('subpath', '.')
        proxy_server = chart_source.get('proxy_server')

        if ct_type == 'local':
            chart['source_dir'] = (location, subpath)
        elif ct_type == 'tar':
            source_key = (ct_type, location)

            if source_key not in self.chart_cache:
                LOG.info("Downloading tarball from: %s / proxy %s", location,
                         proxy_server or "not set")

                if not CONF.certs:
                    LOG.warn(
                        'Disabling server validation certs to extract charts')
                    tarball_dir = source.get_tarball(location,
                                                     verify=False,
                                                     proxy_server=proxy_server)
                else:
                    tarball_dir = source.get_tarball(location,
                                                     verify=CONF.certs,
                                                     proxy_server=proxy_server)
                self.chart_cache[source_key] = tarball_dir
            chart['source_dir'] = (self.chart_cache.get(source_key), subpath)
        elif ct_type == 'git':
            reference = chart_source.get('reference', 'master')
            source_key = (ct_type, location, reference)

            if source_key not in self.chart_cache:
                auth_method = chart_source.get('auth_method')

                logstr = 'Cloning repo: {} from branch: {}'.format(
                    location, reference)
                if proxy_server:
                    logstr += ' proxy: {}'.format(proxy_server)
                if auth_method:
                    logstr += ' auth method: {}'.format(auth_method)
                LOG.info(logstr)

                repo_dir = source.git_clone(location,
                                            reference,
                                            proxy_server=proxy_server,
                                            auth_method=auth_method)

                self.chart_cache[source_key] = repo_dir
            chart['source_dir'] = (self.chart_cache.get(source_key), subpath)
        else:
            name = ch['metadata']['name']
            raise source_exceptions.ChartSourceException(ct_type, name)

        for dep in ch.get(const.KEYWORD_DATA, {}).get('dependencies', []):
            self.get_chart(dep)
Exemple #6
0
    def tag_cloned_repo(self, ch, repos):
        chart = ch.get('chart', {})
        chart_source = chart.get('source', {})
        location = chart_source.get('location')
        ct_type = chart_source.get('type')
        subpath = chart_source.get('subpath', '.')

        if ct_type == 'local':
            chart['source_dir'] = (location, subpath)
        elif ct_type == 'tar':
            LOG.info('Downloading tarball from: %s', location)

            if not CONF.certs:
                LOG.warn('Disabling server validation certs to extract charts')
                tarball_dir = source.get_tarball(location, verify=False)
            else:
                tarball_dir = source.get_tarball(location, verify=CONF.cert)

            chart['source_dir'] = (tarball_dir, subpath)
        elif ct_type == 'git':
            reference = chart_source.get('reference', 'master')
            repo_branch = (location, reference)

            if repo_branch not in repos:
                auth_method = chart_source.get('auth_method')
                proxy_server = chart_source.get('proxy_server')

                logstr = 'Cloning repo: {} from branch: {}'.format(
                    *repo_branch)
                if proxy_server:
                    logstr += ' proxy: {}'.format(proxy_server)
                if auth_method:
                    logstr += ' auth method: {}'.format(auth_method)
                LOG.info(logstr)

                repo_dir = source.git_clone(*repo_branch,
                                            proxy_server=proxy_server,
                                            auth_method=auth_method)
                self.cloned_dirs.add(repo_dir)

                repos[repo_branch] = repo_dir
                chart['source_dir'] = (repo_dir, subpath)
            else:
                chart['source_dir'] = (repos.get(repo_branch), subpath)
        else:
            chart_name = chart.get('chart_name')
            raise source_exceptions.ChartSourceException(ct_type, chart_name)
Exemple #7
0
 def test_source_cleanup(self, mock_log):
     url = 'http://github.com/att-comdev/armada'
     git_path = source.git_clone(url)
     source.source_cleanup(git_path)
     mock_log.warning.assert_not_called()
Exemple #8
0
    def test_git_clone_bad_url(self):
        url = 'http://github.com/dummy/armada'

        with self.assertRaises(Exception):
            source.git_clone(url)
Exemple #9
0
    def test_git_clone_empty_url(self):
        url = ''

        with self.assertRaises(Exception):
            self.assertFalse(source.git_clone(url))
Exemple #10
0
 def test_source_cleanup(self, mock_log):
     url = 'https://opendev.org/airship/armada.git'
     git_path = source.git_clone(url)
     source.source_cleanup(git_path)
     mock_log.warning.assert_not_called()
Exemple #11
0
 def test_git_clone_ref(self):
     ref = 'refs/changes/54/457754/73'
     git_dir = source.git_clone(
         'https://github.com/openstack/openstack-helm', ref)
     self._validate_git_clone(git_dir, ref)
Exemple #12
0
 def test_git_clone_good_url(self):
     url = 'http://github.com/att-comdev/armada'
     git_dir = source.git_clone(url)
     self._validate_git_clone(git_dir)
Exemple #13
0
 def test_git_clone_commit(self):
     url = 'http://github.com/att-comdev/armada'
     commit = 'cba78d1d03e4910f6ab1691bae633c5bddce893d'
     git_dir = source.git_clone(url, commit)
     self._validate_git_clone(git_dir)
Exemple #14
0
 def test_git_clone_good_url(self):
     url = 'https://opendev.org/airship/armada.git'
     git_dir = source.git_clone(url)
     self._validate_git_clone(git_dir)
Exemple #15
0
 def test_git_clone_commit(self):
     url = 'https://opendev.org/airship/armada.git'
     commit = 'cba78d1d03e4910f6ab1691bae633c5bddce893d'
     git_dir = source.git_clone(url, commit)
     self._validate_git_clone(git_dir, commit)
Exemple #16
0
 def test_git_clone_commit(self):
     url = 'https://github.com/openstack/airship-armada'
     commit = 'cba78d1d03e4910f6ab1691bae633c5bddce893d'
     git_dir = source.git_clone(url, commit)
     self._validate_git_clone(git_dir, commit)
Exemple #17
0
 def test_git_clone_good_url(self):
     url = 'https://github.com/openstack/airship-armada'
     git_dir = source.git_clone(url)
     self._validate_git_clone(git_dir)
Exemple #18
0
 def test_source_cleanup(self, mock_log):
     url = 'https://github.com/openstack/airship-armada'
     git_path = source.git_clone(url)
     source.source_cleanup(git_path)
     mock_log.warning.assert_not_called()