Skip to content

Commit

Permalink
Update response format for aks mesh get upgrades and revisions comman…
Browse files Browse the repository at this point in the history
…ds (#7033)
  • Loading branch information
deveshdama authored Dec 4, 2023
1 parent d949d0a commit 104be06
Show file tree
Hide file tree
Showing 6 changed files with 316 additions and 354 deletions.
1 change: 1 addition & 0 deletions src/aks-preview/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ To release a new version, please select a new version number (usually plus 1 to

Pending
+++++++
* Fix the response format for `az aks mesh get-revisions` and `az aks mesh get-upgrades`.

0.5.173
+++++++
Expand Down
4 changes: 2 additions & 2 deletions src/aks-preview/azext_aks_preview/_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ def _aks_snapshot_table_format(result):

def aks_mesh_revisions_table_format(result):
"""Format a list of mesh revisions as summary results for display with "-o table". """
revision_table = flatten_mesh_revision_table(result[0]['properties']['meshRevisions'])
revision_table = flatten_mesh_revision_table(result['meshRevisions'])
parsed = compile_jmes("""[].{
revision: revision,
upgrades: upgrades || [`None available`] | sort_versions(@) | join(`, `, @),
Expand All @@ -343,7 +343,7 @@ def flatten_mesh_revision_table(revision_info):

def aks_mesh_upgrades_table_format(result):
"""Format a list of mesh upgrades as summary results for display with "-o table". """
upgrades_table = _format_mesh_revision_entry(result[0]['properties'])
upgrades_table = _format_mesh_revision_entry(result)
parsed = compile_jmes("""[].{
revision: revision,
upgrades: upgrades || [`None available`] | sort_versions(@) | join(`, `, @),
Expand Down
26 changes: 24 additions & 2 deletions src/aks-preview/azext_aks_preview/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -2589,7 +2589,18 @@ def aks_mesh_get_revisions(
client,
location
):
return client.list_mesh_revision_profiles(location)
revisonProfiles = client.list_mesh_revision_profiles(location)
# 'revisonProfiles' is an ItemPaged object
revisions = []
# Iterate over items within pages
for page in revisonProfiles.by_page():
for item in page:
revisions.append(item)

if revisions:
return revisions[0].properties
else:
return None


def aks_mesh_get_upgrades(
Expand All @@ -2598,7 +2609,18 @@ def aks_mesh_get_upgrades(
resource_group_name,
name
):
return client.list_mesh_upgrade_profiles(resource_group_name, name)
upgradeProfiles = client.list_mesh_upgrade_profiles(resource_group_name, name)
# 'upgradeProfiles' is an ItemPaged object
upgrades = []
# Iterate over items within pages
for page in upgradeProfiles.by_page():
for item in page:
upgrades.append(item)

if upgrades:
return upgrades[0].properties
else:
return None


def aks_mesh_upgrade_start(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,36 +13,44 @@ interactions:
ParameterSetName:
- -l
User-Agent:
- AZURECLI/2.53.0 azsdk-python-azure-mgmt-containerservice/26.0.0b Python/3.8.10
(Linux-6.2.0-1012-azure-x86_64-with-glibc2.29)
- AZURECLI/2.54.0 azsdk-python-azure-mgmt-containerservice/28.0.0b Python/3.8.10
(Linux-6.2.0-1016-azure-x86_64-with-glibc2.29)
method: GET
uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.ContainerService/locations/westus2/meshRevisionProfiles?api-version=2023-10-02-preview
response:
body:
string: "{\n \"value\": [\n {\n \"id\": \"/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.ContainerService/locations/westus2/meshRevisionProfiles/istio\",\n
\ \"name\": \"istio\",\n \"type\": \"Microsoft.ContainerService/locations/meshRevisionProfiles\",\n
\ \"properties\": {\n \"meshRevisions\": [\n {\n \"revision\":
\"asm-1-17\",\n \"compatibleWith\": [\n {\n \"name\":
\"kubernetes\",\n \"versions\": [\n \"1.25.6\",\n \"1.25.11\",\n
\ \"1.26.3\",\n \"1.26.6\",\n \"1.27.1\",\n \"1.27.3\"\n
\ ]\n }\n ]\n }\n ]\n }\n }\n ]\n }"
\"asm-1-17\",\n \"upgrades\": [\n \"asm-1-18\"\n ],\n \"compatibleWith\":
[\n {\n \"name\": \"kubernetes\",\n \"versions\": [\n
\ \"1.25.11\",\n \"1.25.15\",\n \"1.26.6\",\n \"1.26.10\",\n
\ \"1.27.3\",\n \"1.27.7\",\n \"1.28.0\",\n \"1.28.3\"\n
\ ]\n }\n ]\n },\n {\n \"revision\": \"asm-1-18\",\n
\ \"compatibleWith\": [\n {\n \"name\": \"kubernetes\",\n
\ \"versions\": [\n \"1.25.11\",\n \"1.25.15\",\n
\ \"1.26.6\",\n \"1.26.10\",\n \"1.27.3\",\n \"1.27.7\",\n
\ \"1.28.0\",\n \"1.28.3\"\n ]\n }\n ]\n
\ }\n ]\n }\n }\n ]\n }"
headers:
cache-control:
- no-cache
content-length:
- '617'
- '1040'
content-type:
- application/json
date:
- Tue, 10 Oct 2023 20:15:25 GMT
- Sat, 25 Nov 2023 12:31:30 GMT
expires:
- '-1'
pragma:
- no-cache
server:
- nginx
strict-transport-security:
- max-age=31536000; includeSubDomains
transfer-encoding:
- chunked
vary:
- Accept-Encoding
x-content-type-options:
- nosniff
status:
Expand Down
Loading

0 comments on commit 104be06

Please sign in to comment.