我需要根据一些标签过滤器列出所有应用程序。
https://argocd_domain/api/v1/applications
为了列出来自 argoCD API 的所有应用,我想放置所有可能的过滤器。
最佳答案
Argo CD API 记录在其 Swagger document 中。
将该 JSON 复制并粘贴到 Swagger Editor ,您将获得一个格式良好的描述 API 的页面。这是列出应用程序的部分:
function to handle a list-applications request 调用 ConvertSelectorToLabelsMap
。读取 the implementation of that parsing function ,您可以找到 selector
参数的预期格式。
乍一看,格式似乎是一个以逗号分隔的 key=value
对列表。
使用 Swagger 编辑器,我生成了这个测试 URL:
curl -X GET "https://editor.swagger.io/api/v1/applications?selector=label1%3Dvalue1%2Clabel2%3Dvalue2" -H "accept: application/json"
看起来您需要对等号和逗号进行 URL 编码。
关于argoproj - 我在哪里可以获得 ArgoCD api 的深入文档,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63558600/