def run(self): """ run the plugin """ if self.workflow.builder.base_from_scratch and not self.workflow.builder.parent_images: self.log.info( "Skipping add yum repo by url: unsupported for FROM-scratch images" ) return if self.repourls: for repourl in self.repourls: yumrepo = YumRepo(repourl) self.log.info("fetching yum repo from '%s'", yumrepo.repourl) try: yumrepo.fetch() except Exception as e: msg = "Failed to fetch yum repo {repo}: {exc}".format( repo=yumrepo.repourl, exc=e) raise RuntimeError(msg) else: self.log.info("fetched yum repo from '%s'", yumrepo.repourl) if self.inject_proxy: if yumrepo.is_valid(): yumrepo.set_proxy_for_all_repos(self.inject_proxy) self.workflow.files[yumrepo.dst_filename] = yumrepo.content self.log.debug("saving yum repo '%s', length %d", yumrepo.dst_filename, len(yumrepo.content))
def extract_base_url(self, repo_url): yum_repo = YumRepo(repo_url) yum_repo.fetch() if not yum_repo.is_valid(): return [] repo = yum_repo.config return [repo.get(section, 'baseurl') for section in repo.sections() if repo.has_option(section, 'baseurl')]
def extract_base_url(self, repo_url): yum_repo = YumRepo(repo_url) yum_repo.fetch() if not yum_repo.is_valid(): return [] repo = yum_repo.config return [repo.get(section, 'baseurl') for section in repo.sections() if repo.has_option(section, 'baseurl')]
def run(self): """ run the plugin """ if self.repourls: for repourl in self.repourls: yumrepo = YumRepo(repourl) yumrepo.fetch() self.log.info("fetched repo from '%s'", yumrepo.repourl) if self.inject_proxy: if yumrepo.is_valid(): yumrepo.set_proxy_for_all_repos(self.inject_proxy) self.workflow.files[yumrepo.dst_filename] = yumrepo.content self.log.debug("saving repo '%s', length %d", yumrepo.dst_filename, len(yumrepo.content))