设置带有环境变量的布尔字段时的牧场主错误



我有一个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。其次,使用模板逻辑获取布尔变量的值。

  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

最新更新