Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Yaml 使用环境变量设置布尔字段时出现Rancher错误_Yaml_Unmarshalling_Rancher - Fatal编程技术网

Yaml 使用环境变量设置布尔字段时出现Rancher错误

Yaml 使用环境变量设置布尔字段时出现Rancher错误,yaml,unmarshalling,rancher,Yaml,Unmarshalling,Rancher,我有一个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:

我有一个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
升级策略:
批量:1

先开始:“false”#我遇到了同样的问题,并使用了不同的策略来解决问题。第一步是将
docker compose.yml
转换为模板,
docker compose.yml.tpl
。其次,使用模板逻辑获取布尔变量的值

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

参考资料:

与我的解决方案类似-由于rancher compose是从makefile运行的,因此我创建了一个模板,然后使用sed替换了相关值