1

我正在尝试读取在 ConfigMap 中存储为 Json 的 url 列表,然后将这些作为参数传递给我的 Argo 工作流程的下一步。

我的配置图如下所示:

apiVersion: v1
kind: ConfigMap
metadata:
  name: urls
data:
  urls: |
    [
      {"url": "https://www.google.com/"},
      {"url": "https://stackoverflow.com/"}
    ]

我的工作流模板如下所示(为简洁起见,省略了元数据):

  templates:
  - name: main
    dag:
      tasks:

      - name: get-urls
        template: urls

      - name: url-thingy
        dependencies: ['get-urls']
        templateRef: 
          name: do-thing-with-the-urls
          template: url-thing
        arguments:
          parameters: 
          - name: url
            value: "{{ item.url }}"
        withParam: "{{tasks['get-urls'].outputs.result}}"

  - name: urls
    resource:
      action: get
      manifest: |
        apiVersion: v1
        kind: ConfigMap
        metadata:
          name: urls
    outputs:
      parameters:
      - name: urls
        valueFrom:
          jsonPath: '{.data.urls}'

get-urls这会加载 ConfigMap 文件,我可以看到输出下的步骤中列出的 url 。当它尝试执行该url-thingy步骤时,它会失败并显示以下消息:

withParam value could not be parsed as a JSON list: {{tasks['get-urls'].outputs.result}}: invalid character '{' looking for beginning of object key string

我觉得我接近解决方案,但我不确定我哪里出错了?withParam 是访问我的列表的正确方法吗?

4

1 回答 1

0

尝试{{=toJson(tasks['get-urls'].outputs.result)}}

于 2022-02-16T22:36:56.900 回答