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)
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)
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)