当前位置: 首页>>代码示例>>Python>>正文


Python DockerfileParser.get方法代码示例

本文整理汇总了Python中dockerfile_parse.DockerfileParser.get方法的典型用法代码示例。如果您正苦于以下问题:Python DockerfileParser.get方法的具体用法?Python DockerfileParser.get怎么用?Python DockerfileParser.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在dockerfile_parse.DockerfileParser的用法示例。


在下文中一共展示了DockerfileParser.get方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from dockerfile_parse import DockerfileParser [as 别名]
# 或者: from dockerfile_parse.DockerfileParser import get [as 别名]
    def __init__(self, tasker, workflow, nvr=None, destdir="/root/buildinfo/",
                 use_final_dockerfile=False):
        """
        constructor

        :param tasker: DockerTasker instance
        :param workflow: DockerBuildWorkflow instance
        :param nvr: name-version-release, will be appended to Dockerfile-.
                    If not specified, try to get it from Name, Version, Release labels.
        :param destdir: directory in the image to put Dockerfile-N-V-R into
        :param use_final_dockerfile: bool, when set to True, uses final version of processed dockerfile,
                                     when set to False, uses Dockerfile from time when this plugin was executed
        """
        # call parent constructor
        super(AddDockerfilePlugin, self).__init__(tasker, workflow)

        self.use_final_dockerfile = use_final_dockerfile

        if nvr is None:
            labels = DockerfileParser(self.workflow.builder.df_path).labels
            name = labels.get('Name')
            version = labels.get('Version')
            release = labels.get('Release')
            if name is None or version is None or release is None:
                raise ValueError("You have to specify either nvr arg or Name/Version/Release labels.")
            nvr = "{0}-{1}-{2}".format(name, version, release)
            nvr = nvr.replace("/", "-")
        self.df_name = '{0}-{1}'.format(DOCKERFILE_FILENAME, nvr)
        self.df_dir = destdir
        self.df_path = os.path.join(self.df_dir, self.df_name)

        # we are not using final dockerfile, so let's copy current snapshot
        if not self.use_final_dockerfile:
            local_df_path = os.path.join(self.workflow.builder.df_dir, self.df_name)
            shutil.copy2(self.workflow.builder.df_path, local_df_path)
开发者ID:TomasTomecek,项目名称:atomic-reactor,代码行数:37,代码来源:pre_add_dockerfile.py

示例2: run

# 需要导入模块: from dockerfile_parse import DockerfileParser [as 别名]
# 或者: from dockerfile_parse.DockerfileParser import get [as 别名]
 def run(self):
     """
     run the plugin
     """
     labels = DockerfileParser(self.workflow.builder.df_path).labels
     for label in self.required_labels:
         if labels.get(label) is None:
             msg = "Dockerfile is missing '{0}' label.".format(label)
             self.log.error(msg)
             raise AssertionError(msg)
开发者ID:TomasTomecek,项目名称:atomic-reactor,代码行数:12,代码来源:pre_assert_labels.py


注:本文中的dockerfile_parse.DockerfileParser.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。