Skip to content

Commit 389ebe7

Browse files
authored
{AKS} Wrap the ARG call logic in the managed namespace list command (#8825)
1 parent 36ee211 commit 389ebe7

File tree

6 files changed

+996
-471
lines changed

6 files changed

+996
-471
lines changed

src/aks-preview/HISTORY.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ To release a new version, please select a new version number (usually plus 1 to
1212
Pending
1313
+++++++
1414

15+
18.0.0b10
16+
+++++++
17+
* Wrap the ARG call in the managed namespace list command
18+
1519
18.0.0b9
1620
+++++++
1721
* Add `--max-blocked-nodes` to the `az aks nodepool add/update/upgrade` commands.

src/aks-preview/azext_aks_preview/_format.py

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -93,21 +93,28 @@ def aks_namespace_list_table_format(results):
9393

9494

9595
def _aks_namespace_list_table_format(result):
96-
parsed = compile_jmes("""{
97-
name: name,
98-
tags: to_string(tags),
99-
provisioningState: to_string(properties.provisioningState),
100-
labels: to_string(properties.labels),
101-
annotations: to_string(properties.annotations),
102-
cpuRequest: to_string(properties.defaultResourceQuota.cpuRequest),
103-
cpuLimit: to_string(properties.defaultResourceQuota.cpuLimit),
104-
memoryRequest: to_string(properties.defaultResourceQuota.memoryRequest),
105-
memoryLimit: to_string(properties.defaultResourceQuota.memoryLimit),
106-
ingress: to_string(properties.defaultNetworkPolicy.ingress),
107-
egress: to_string(properties.defaultNetworkPolicy.egress),
108-
adoptionPolicy: to_string(properties.adoptionPolicy),
109-
deletePolicy: to_string(properties.deletePolicy)
110-
}""")
96+
if not result.get("properties"):
97+
parsed = compile_jmes("""{
98+
name: name,
99+
resourceGroup: resourceGroup,
100+
location: location
101+
}""")
102+
else:
103+
parsed = compile_jmes("""{
104+
name: name,
105+
tags: to_string(tags),
106+
provisioningState: to_string(properties.provisioningState),
107+
labels: to_string(properties.labels),
108+
annotations: to_string(properties.annotations),
109+
cpuRequest: to_string(properties.defaultResourceQuota.cpuRequest),
110+
cpuLimit: to_string(properties.defaultResourceQuota.cpuLimit),
111+
memoryRequest: to_string(properties.defaultResourceQuota.memoryRequest),
112+
memoryLimit: to_string(properties.defaultResourceQuota.memoryLimit),
113+
ingress: to_string(properties.defaultNetworkPolicy.ingress),
114+
egress: to_string(properties.defaultNetworkPolicy.egress),
115+
adoptionPolicy: to_string(properties.adoptionPolicy),
116+
deletePolicy: to_string(properties.deletePolicy)
117+
}""")
111118
# use ordered dicts so headers are predictable
112119
return parsed.search(result, Options(dict_cls=OrderedDict))
113120

src/aks-preview/azext_aks_preview/custom.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,10 @@
121121
ValidationError,
122122
)
123123
from azure.cli.core.commands import LongRunningOperation
124-
from azure.cli.core.commands.client_factory import get_subscription_id
124+
from azure.cli.core.commands.client_factory import (
125+
get_subscription_id,
126+
get_mgmt_service_client,
127+
)
125128
from azure.cli.core.profiles import ResourceType
126129
from azure.cli.core.util import (
127130
in_cloud_console,
@@ -326,10 +329,20 @@ def aks_namespace_show(
326329
def aks_namespace_list(
327330
cmd, # pylint: disable=unused-argument
328331
client,
329-
resource_group_name,
330-
cluster_name
332+
resource_group_name=None,
333+
cluster_name=None,
331334
):
332-
return client.list_by_managed_cluster(resource_group_name, cluster_name)
335+
if resource_group_name and cluster_name:
336+
return client.list_by_managed_cluster(resource_group_name, cluster_name)
337+
rcf = get_mgmt_service_client(cmd.cli_ctx, ResourceType.MGMT_RESOURCE_RESOURCES)
338+
full_resource_type = "Microsoft.ContainerService/managedClusters/managedNamespaces"
339+
filters = [f"resourceType eq '{full_resource_type}'"]
340+
if resource_group_name:
341+
filters.append(f"resourceGroup eq '{resource_group_name}'")
342+
odata_filter = " and ".join(filters)
343+
expand = "createdTime,changedTime,provisioningState"
344+
resources = rcf.resources.list(filter=odata_filter, expand=expand)
345+
return list(resources)
333346

334347

335348
def aks_namespace_delete(

0 commit comments

Comments
 (0)