
theanurin/configuration-templates配置模板(Configuration Templates)是一套针对配置属性运行的模板处理器集合,能够根据配置源动态生成配置文件,支持多种模板引擎和配置文件格式,适用于需要动态配置生成的场景。
适用于需要根据环境变量、配置文件等动态生成配置的场景,例如:
无特殊环境变量要求
/data:默认工作目录,可挂载本地配置目录至此以访问配置文件用于指定配置源的命令参数:
--config-file=common.config:从普通键值对文件(key=value格式)加载属性,可多次使用以指定多个文件--config-toml-file=common.toml:从TOML格式配置文件加载属性,可多次使用以指定多个文件--config-env:从环境变量加载属性镜像内部包含以下组件:
shellecho "<h1>Hello, {{NAME}} {{SURNAME}}</h1>{% for el in item['\$array'] %}<p>{{el.name}}</p><br/>{% endfor %}" | docker run \ --interactive --rm \ --env NAME="World" --env item.1.name=1 --env item.2.name=2 \ theanurin/configuration-templates:20251014 \ --engine liquid \ --config-env # 输出:<h1>Hello, World </h1><p>1</p><br/><p>2</p><br/>
shellecho '<h1>Hello, {{NAME}} {{SURNAME}}</h1>{{#item.$array}}<p>{{name}}</p><br/>{{/item.$array}}' | docker run \ --interactive --rm \ --env NAME="World" --env item.1.name=1 --env item.2.name=2 \ theanurin/configuration-templates:20251014 \ --engine mustache \ --config-env # 输出:<h1>Hello, World </h1><p>1</p><br/><p>2</p><br/>
shellecho "<h1>Hello, {{NAME}} {{?SURNAME}}</h1>" | \ docker run \ --interactive --rm \ --volume /path/to/configs:/data \ # 挂载本地配置目录至/data --env NAME="World" \ theanurin/configuration-templates:20251014 \ --engine mustache \ --config-file=common.config \ # 加载键值配置文件 --config-file=devel.config \ # 加载第二个键值配置文件 --config-toml-file=devel.toml \ # 加载TOML配置文件 --config-env # 同时加载环境变量
模板中可使用以下特殊属性处理数据结构:
$parent:指向父数据节点$root:指向根数据节点$array:将当前对象转换为数组形式$single:约束为父命名空间中的单个属性
manifest unknown 错误
TLS 证书验证失败
DNS 解析超时
410 错误:版本过低
402 错误:流量耗尽
身份认证失败错误
429 限流错误
凭证保存错误
来自真实用户的反馈,见证轩辕镜像的优质服务