1

我正在寻找一种使用 webhook json 有效负载键触发工作流的方法,例如如果有效负载是 {"action":"copy","id":"someid"}

在触发器上

triggers:
   template:
    - "group1"
      "use this template if action key is 'copy'"
    - "group2"
      "use this template" if action key is 'move'"

我创建了一个示例传感器文件,但是 argo sersor 抱怨 eventSourceName 使用了多次。

apiVersion: argoproj.io/v1alpha1
kind: Sensor
metadata:
  name: testing-sensor
spec:
  template:
    serviceAccountName: argo 
  dependencies:
    - name: data
      eventSourceName: testhook
      eventName: test
      filters:
        data:
          - path: body.message
            type: string
            value:
              - copy
    
    - name: data1
      eventSourceName: testhook
      eventName: test
      filters:
        data:
          - path: body.message
            type: string
            value:
              - move
  triggers:
    - template:
        conditions: "data"
        name: group-1
        
    - template:
        conditions: "data1"
        name: group-2
         

如果有人可以提供帮助,那就太好了

4

1 回答 1

1

您应该在传感器中使用数据过滤器。(示例传感器。)

它看起来像这样:

apiVersion: argoproj.io/v1alpha1
kind: Sensor
metadata:
  name: data-filter
spec:
  dependencies:
    - name: test-dep
      eventSourceName: webhook
      eventName: example
      filters:
        data:
          - path: body.action
            type: string
            value:
              - "copy"
  triggers:
    - template:
        name: data-workflow
        k8s:
          group: argoproj.io
          version: v1alpha1
          resource: workflows
          operation: create
# ...
于 2021-05-03T13:00:47.660 回答