我有一个通过 Argo Events 和 PubSub 触发的 WorkflowTemplate “nyc-test-template”。因此,如果我将消息发布{}
到 PubSub 主题“argo-events-nyc”,则通过 a 指定的模板workflowTempateRef
将启动。这确实工作得很好。现在我想参数化要启动的模板。
我的不工作草稿如下所示:
apiVersion: argoproj.io/v1alpha1
kind: EventSource
metadata:
name: pubsub-event-source-nyc
spec:
template:
serviceAccountName: argo-events
pubSub:
examplex:
jsonBody: true
topic: argo-events-nyc
subscriptionID: argo-events-nyc-sub
---
apiVersion: argoproj.io/v1alpha1
kind: Sensor
metadata:
name: pubsub-sensor-nyc
spec:
template:
serviceAccountName: argo-events-sa
dependencies:
- name: pubsub-event-source-dep
eventSourceName: pubsub-event-source-nyc
eventName: examplex
triggers:
- template:
name: argo-workflow-trigger
argoWorkflow:
group: argoproj.io
version: v1alpha1
resource: workflows
operation: submit
source:
resource:
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: nyc-test-template-
namespace: argo
spec:
arguments:
parameters:
- name: wft
value: nyc-test-template
workflowTemplateRef:
# I'm pretty sure this inputs block is useless. But leaving it out
# and instead referencing arguments.parameters.wft won't work either.
inputs:
parameters:
- name: wft
name: "{{inputs.parameters.wft}}"
parameters:
- src:
dependencyName: pubsub-event-source-dep
dataKey: body.wft
dest: spec.arguments.parameters.0.value
我想要发生的是这样的:
- 一条空消息
{}
将触发“nyc-test-template” - 该消息
{"wft": "my-template"}
将触发“我的模板”
相反,发布空消息会导致传感器抛出错误:
2021-03-29T15:31:16.386441528Z2021/03/29 15:31:16 Failed to parse workflow: error unmarshaling JSON: while decoding JSON: json: unknown field "inputs"
坦白说,上面的 yaml 就是从这个例子中得到了粗略的启发。这并不是有根据的猜测的结果,因为我仍然不了解参数、参数和输入如何交互的机制。