file_config.py 文件源码

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

项目:simphony-remote 作者: simphony 项目源码 文件源码
def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        # Sets the default of the docker configuration options from the
        # current environment. These will possibly be overridded by
        # the appropriate entries in the configuration file when parse_file
        # is invoked

        env = os.environ

        self.docker_host = env.get("DOCKER_HOST", "")
        if self.docker_host == "":
            self.docker_host = "unix://var/run/docker.sock"

        # Note that definedness, not value, is considered, meaning
        # that defining DOCKER_TLS_VERIFY=0 will still evaluate to True.
        # This is consistent with both docker behavior and general shell
        # practice.
        self.tls_verify = (env.get("DOCKER_TLS_VERIFY", "") != "")
        # We don't have an envvar way of saying TLS = True, so we rely on
        # TLS_VERIFY set status
        self.tls = self.tls_verify

        cert_path = env.get("DOCKER_CERT_PATH",
                            os.path.join(os.path.expanduser("~"), ".docker"))

        self.tls_cert = os.path.join(cert_path, 'cert.pem')
        self.tls_key = os.path.join(cert_path, 'key.pem')
        self.tls_ca = os.path.join(cert_path, 'ca.pem')

        if self.tls:
            self.docker_host = self.docker_host.replace('tcp://', 'https://')

    # -------------------------------------------------------------------------
    # Public
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号