我在 Argo
WorkflowTemplate
中定义了一个脚本,如下所示。这可以打印 status:true
或 status:false
(我已经简化了)
- name:util-script
script:
image: python3
command: ["python3"]
script |
print(status:true)
有没有办法根据上面的脚本输出来控制dag流?我知道 helm 提供了流程控制,例如 Helm Doc - Flow control
以下是我到目前为止所尝试的,但这总是跳转到
else
条件。我做错了什么吗?感谢对此的任何意见
{{- if contains "status:true" `tasks.util-script.outputs.result` }}
# even result is `status:true`, does not reach here
{{ else }}
# always reach here
{{ end }}
我已经验证
tasks.util-script.outputs.result
确实返回了预期的结果。
Helm 在工作流程运行之前执行。这就是为什么你最终会进入 else 块。
您需要使用
when
条件,如文档中所示 - https://argo-workflows.readthedocs.io/en/stable/walk-through/conditionals/
- name: next
template: next
when: {{`{{tasks.util-script.outputs.result}}`}} == "status:true"