def run(self):
        """
        run the plugin
        """
        yum_repos = {
            k: v
            for k, v in self.workflow.files.items()
            if k.startswith(YUM_REPOS_DIR)
        }
        if not yum_repos:
            return
        # absolute path in containers -> relative path within context
        host_repos_path = os.path.join(self.workflow.builder.df_dir,
                                       RELATIVE_REPOS_PATH)
        self.log.info("creating directory for yum repos: %s", host_repos_path)
        os.mkdir(host_repos_path)

        for repo, repo_content in self.workflow.files.items():
            yum_repo = YumRepo(repourl=repo,
                               content=repo_content,
                               dst_repos_dir=host_repos_path,
                               add_hash=False)
            yum_repo.write_content()

        # Find out the USER inherited from the base image
        inspect = self.workflow.builder.base_image_inspect
        inherited_user = ''
        if not self.workflow.builder.base_from_scratch:
            inherited_user = inspect.get(INSPECT_CONFIG).get('User', '')
        df = df_parser(self.workflow.builder.df_path, workflow=self.workflow)
        yum_repos = list(self.workflow.files)
        add_yum_repos_to_dockerfile(yum_repos, df, inherited_user,
                                    self.workflow.builder.base_from_scratch)
    def run(self):
        """
        run the plugin
        """
        yum_repos = {k: v for k, v in self.workflow.files.items() if k.startswith(YUM_REPOS_DIR)}
        if not yum_repos:
            return
        # absolute path in containers -> relative path within context
        host_repos_path = os.path.join(self.workflow.builder.df_dir, RELATIVE_REPOS_PATH)
        self.log.info("creating directory for yum repos: %s", host_repos_path)
        os.mkdir(host_repos_path)

        for repo, repo_content in self.workflow.files.items():
            yum_repo = YumRepo(repourl=repo, content=repo_content, dst_repos_dir=host_repos_path,
                               add_hash=False)
            yum_repo.write_content()

        # Find out the USER inherited from the base image
        inspect = self.workflow.builder.base_image_inspect
        inherited_user = ''
        if not self.workflow.builder.base_from_scratch:
            inherited_user = inspect.get(INSPECT_CONFIG).get('User', '')
        df = df_parser(self.workflow.builder.df_path, workflow=self.workflow)
        yum_repos = list(self.workflow.files)
        add_yum_repos_to_dockerfile(yum_repos, df, inherited_user,
                                    self.workflow.builder.base_from_scratch)
示例#3
0
def test_write_content(tmpdir):
    test_content = 'test_content'
    repo = YumRepo(repourl='http://example.com/a/b/c/myrepo.repo',
                   content=test_content,
                   dst_repos_dir=str(tmpdir))
    repo.write_content()

    with open(os.path.join(str(tmpdir), repo.filename)) as f:
        assert f.read() == test_content
def test_write_content(tmpdir):
    test_content = 'test_content'
    repo = YumRepo(
        repourl='http://example.com/a/b/c/myrepo.repo', content=test_content,
        dst_repos_dir=str(tmpdir)
    )
    repo.write_content()

    with open(os.path.join(str(tmpdir), repo.filename)) as f:
        assert f.read() == test_content