gpt4 book ai didi

yaml - 使用环境变量设置 bool 字段时发生 Rancher 错误

转载 作者:行者123 更新时间:2023-12-02 04:34:20 26 4
gpt4 key购买 nike

我有一个 rancher-compose.yml 文件,其中使用如下环境变量设置了upgrade_strategy.start_first 字段:

  upgrade_strategy:
start_first: ${START_FIRST}
batch_size: 1

使用 rancher-compose CLI 运行时,出现以下错误:

ERRO[0000] Failed to open project origami-svcproxy: yaml: unmarshal errors:
line 28: cannot unmarshal !!str `false` into bool

在调试中运行时,我看到以下 yaml:

  upgrade_strategy:
batch_size: 1
start_first: "false" # <-- notice the surrounding quotes, missing from the rest of the variable replacements

如何动态设置该字段?

最佳答案

我遇到了同样的问题,并使用了不同的策略来解决该问题。第一步是将 docker-compose.yml 转换为模板 docker-compose.yml.tpl。其次,使用模板逻辑获取 bool 变量的值。

  upgrade_strategy:
start_first: {{ .Values.START_FIRST }}
batch_size: 1

引用:https://github.com/rancher/rancher-catalog/blob/v1.6-development/infra-templates/ipsec/9/docker-compose.yml.tpl#L21

关于yaml - 使用环境变量设置 bool 字段时发生 Rancher 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37907268/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com