从我的 Argo 工作流程中的 ConfigMap 获取值

问题描述 投票:0回答:1

我的 Argo 工作流程有一个模板,可生成以下配置图:

{
  "apiVersion": "v1",
  "kind": "ConfigMap",
  "metadata": { "name": "configmap" },
  "data":
    {
      "ELASTIC_SEARCH_URL": "https://staging-aaa.domain.com",
      "EXTENSION_PATH": "/dist",
      "GRAPHQL_GATEWAY_URL": "https://graphql-gateway.stg.domain.com/graphql",
      "bucket_url": "stg-bucket/fie/to/path",
    },
}

我在我的其他模板之一中使用此值,如下所示:

...
envFrom:
- configMapRef:
    name: "{{inputs.parameters.configmap}}"

我还想通过在该输出中获取

bucket_url
来获得“二合一”,因此我创建了此模板来测试我是否能够打印我想要的内容(我不能在原始输出,所以我在
withParam
周围添加了
[]
):
{{steps.create-configmap.outputs.parameters.configmap}}

此模板的输出正是配置映射本身:

- - name: print-with-loop template: print-with-loop-tmpl arguments: parameters: - name: data value: "{{item}}" withParam: "[{{steps.create-configmap.outputs.parameters.configmap}}]"

我还可以在该配置映射中打印 
{apiVersion:v1,data:{ELASTIC_SEARCH_URL:https://staging-aaa.domain.com,EXTENSION_PATH:/dist,GRAPHQL_GATEWAY_URL:https://graphql.stg.domain.com/graphql,bucket_url:stg-bucket/fie/to/path},kind:ConfigMap,metadata:{name:env-configmap}}

item.data

但是我无法访问
{ELASTIC_SEARCH_URL:https://staging-aaa.domain.com,EXTENSION_PATH:/dist,GRAPHQL_GATEWAY_URL:https://graphql.stg.domain.com/graphql,bucket_name:stg-bucket,ext_path:extension/stable/dist-raw.tar.gz,bucket_url:stg-bucket/extension/stable/dist-raw.tar.gz}

内的任何数据。如果我使用

item.data
item.data.bucket_url
,它不起作用,并且我会从 Argo 收到错误。
我尝试使用 

sprig

操作输出,但我无法找到解决方案。基本上我正在尝试获取 item.data['bucket_url'] 以便在此工作流程中的另一个模板中使用。

顺便说一句,在首先生成 ConfigMap 的脚本末尾,我输出如下文件:

bucket_url

也许使用 
with open("/tmp/configmap.json", "w") as file: json.dump(configmap, file)

会对我有所帮助?我没有看到它,但我提供此信息以防万一。

    

yaml go-templates argo
1个回答
0
投票
dumps

:

withParam

由于我正在打印生成 ConfigMap 的脚本中所做的 
- - name: print-with-loop template: print-with-loop-tmpl arguments: parameters: - name: data value: "{{item.bucket_url}}" withParam: "{{steps.create-configmap.outputs.result}}"

,因此我可以轻松访问

json.dump
。上面模板的输出正是我所需要的。
    

© www.soinside.com 2019 - 2024. All rights reserved.