跳转到主要内容

渲染、合并并验证用于部署堆栈的docker_compose文件

项目描述

Stack Config

版本号:0.1.0 作者:ScienceLogic

概述

渲染、合并并验证用于部署堆栈的docker_compose文件。

这个库使用docker-compose合并过程,但最终会进行最终验证,让用户知道这是否是一个有效的用于部署堆栈的docker-compose,因为docker-compose不会进行验证。

此外,这个库将编译有效的yaml jinja2模板,以便它们可以与其他docker-compose文件一起合并。

安装

使用pip进行安装

$ pip install stackconfig

或克隆仓库

$ git clone https://github.com/Sciencelogic/stackconfig.git
$ python setup.py install

开发

  1. 分叉
  2. 设置开发环境
pip install -r dev_requirements.txt
pip install -r requirements.txt
pip install -e .
git checkout -b feature-more-cool-stuff

测试

# run tests using tox
tox
# run tests with pytest
pytest

版本

bumpversion major  # major release
or
bumpversion minor  # minor release
or
bumpversion patch  # hotfix release

git push origin release-n.n.0
or
git push origin hotfix-x.x.n

作为CLI工具的使用示例

$ stackconfig --help
Usage: stackconfig [OPTIONS]

Options:
  -f, --file PATH        docker-compose file to be merged. Accept multiple
                         arguments.
  -o, --output PATH      Output path for the final docker-compose file
                         [default: /tmp/docker-compose-20220425-16-49-16.yml]
  -d, --j2data PATH      Yaml file that contains variables to render the
                         provided jinja2 template.
  -t, --j2template PATH  Jinja2 template that needs to be a valid docker-
                         compose file after being rendered.
  --version TEXT         Set valid version for the final docker-compose file
  --help                 Show this message and exit.
$ stackconfig -f docker-compose.yml -f compose-override.yml -t docker-compose-template.yml.j2 -d data_file.yml --version 3.8 -o docker-compose-final.yml

使用Python的使用示例

from stackconfig.stackconfig import StackConfigCompose
from stackconfig.utils.jinja2_utils import render_jijnja2_compose

jinja_env = {}
yml_compiled_files = render_jijnja2_compose(['/tmp/docker-compose.yml.j2',
                                             '/tmp/docker-compose-override-yml.j2'],
                                            data_file='/tmp/data_file.yml',
                                            data_dict=jinja_env)
# valid docker-compose files can be appended, all of them are going to be merged using the docker-compose library
yml_compiled_files.append("/tmp/docker-copmose-override2.yml")
stack_config = StackConfigCompose(yml_compiled_files, '/tmp/docker-compose-output.yml')
stack_config.merge_stack_compose()

这并不是你想要的?

可能适合你的选项

项目详情


下载文件

下载适合您平台的文件。如果您不确定要选择哪一个,请了解有关安装包的更多信息。

源代码分发

stackconfig-1.0.1.tar.gz (6.8 kB 查看哈希值)

上传时间 源代码

构建分发

stackconfig-1.0.1-py2.py3-none-any.whl (7.3 kB 查看哈希值)

上传时间 Python 2 Python 3

由以下提供支持