generate_dockerfile_action.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:system-buildah 作者: ashcrow 项目源码 文件源码
def run(self, parser, namespace, values, dest, option_string=None):
        """
        Execution of the action.

        :name parser: The argument parser in use.
        :type parser: argparse.ArgumentParser
        :name namespace: The namespace for parsed args.
        :type namespace: argparse.Namespace
        :name values: Values for the action.
        :type values: mixed
        :name option_string: Option string.
        :type option_string: str or None
        :raises: subprocess.CalledProcessError
        """
        hostfs_dirs = []
        add_files = {}
        for item in namespace.add_file:
            local, host = item.split('=')
            hostfs_dirs.append(os.path.dirname(host))
            add_files[local] = host

        output = util.mkdir(namespace.output)
        with open(os.path.sep.join([output, 'Dockerfile']), 'w') as dockerfile:
            loader = jinja2.PackageLoader('system_buildah')
            rendered = loader.load(
                jinja2.Environment(), 'Dockerfile.j2').render(
                    from_base=namespace.from_base, name=values,
                    maintainer=namespace.maintainer,
                    license_name=namespace.license, summary=namespace.summary,
                    version=namespace.version, help_text=namespace.help_text,
                    architecture=namespace.architecture, scope=namespace.scope,
                    add_files=add_files, hostfs_dirs=set(hostfs_dirs))
            dockerfile.write(rendered)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号