首页 > 解决方案 > 填充选项列表时如何在 Extension task.json 中对数据源绑定进行排序和过滤

问题描述

我正在使用 API 在我的实用程序的选择列表中获取可用的 AKS 版本。我只想按从高到低的顺序显示最新的 4 个版本。

我的代码的当前版本提供了该地区的所有可用版本-

{
   "name": "kubeVersion",
  "type": "picklist",
  "label": "Kubernetes Version",
  "defaultValue": "",
  "required": true,
  "helpMarkDown": "Select the version of the Kubernetes that needs to be installed on the AKS cluster.",
 
},
.
.
.
 {
   "target": "kubeVersion",
   "endpointId": "$(ConnectedServiceName)",
   "endpointUrl": "{{{endpoint.url}}}/subscriptions/$(endpoint.subscriptionId)/providers/Microsoft.ContainerService/locations/$(rsgLocation)/orchestrators?api-version=2019-04-01&resource-type=managedClusters",
   "resultSelector": 
   "jsonpath:$.properties.orchestrators[*].orchestratorVersion",
   "parameters": {
    "rsgLocation": "$(rsgLocation)"
  }
},

在上面的代码中,我在选择所有可用值的 jsonpath 中给出 [*]。这就像
1.10.12

1.10.13

.

.

.

1.14.6

1.15.3

你能帮我添加过滤器并在那里排序吗?我想对这些值从最新到最早进行排序,并且只取前 4 个版本。稍后要求可能会更改为 1.X.* 和 1.Y.* 所以我也希望能够过滤。你能告诉我这些是什么类型的符号以及我可以从哪里学习吗?我非常感谢任何满足这些要求的建议。

标签: azureazure-aksazure-devops-extensionsjson-path-expression

解决方案


推荐阅读