小编vpe*_*son的帖子

域名(开发,登台,制作)的最佳做法是什么?

随着容器,Kuberenetes,12 Factor等的增加,在开发,分期和生产中复制相同的环境变得更加容易.但是,域名约定似乎没有共同标准.

据我所知,有两种方法:

  • 使用子域名:
    • *.dev.foobar.tld
    • *.staging.foobar.tld
    • *.foobar.tld
  • 使用单独的域:
    • *.foobar-dev.tld
    • *.foobar-staging.tld
    • *.foobar.tld

我可以用两种方法看到起伏,但我很好奇普通的实践是什么.

作为附注,Cloudflare不会为您发放子子域的证书(例如*.stage.foobar.tld).

ssl paas cloudflare deis kubernetes

27
推荐指数
2
解决办法
1万
查看次数

AttributeError: <module '__main__' from [..] 没有属性 'open'

我正在为docker-py的模块编写测试,但我似乎无法让测试正常工作。

我正在测试的功能如下所示:

def parse_env_file(env_file):
    """
    Reads a line-separated environment file.
    The format of each line should be "key=value".
    """
    environment = []

    if os.path.isfile(env_file):
        with open(env_file, 'r') as f:
            # We can't use f.readlines() here as it's not implemented in Mock
            for line in f.read().split('\n'):
                parse_line = line.strip().split('=')
                if len(parse_line) == 2 and line[0] != '#':
                    k = parse_line[0]
                    v = parse_line[1]
                    environment.append('{0}={1}'.format(k, v))

    return environment
Run Code Online (Sandbox Code Playgroud)

然后测试看起来像这样:

def test_parse_env_file_proper(self):
    with mock.patch('os.path.isfile', return_value=True):
        mock_env_file = 'USER=jdoe\nPASS=secret'
        with mock.patch('{}.open'.format(__name__), mock.mock_open(read_data=mock_env_file)): …
Run Code Online (Sandbox Code Playgroud)

python unit-testing tox

2
推荐指数
1
解决办法
3564
查看次数

标签 统计

cloudflare ×1

deis ×1

kubernetes ×1

paas ×1

python ×1

ssl ×1

tox ×1

unit-testing ×1