Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/aks-preview/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ Pending
+++++++

* Remove defender related code after GA, reuse the implementation in azure-cli/acs.
* Remove check_raw_parameters in update code path, reuse the implementation in azure-cli/acs.

0.5.120
+++++++

* Remove file, blob csi driver and snapshot controller related CSI driver code after GA, reuse the implementation in azure-cli/acs.
* Remove Azure Dedicated Host related code after GA, reuse the implementation in azure-cli/acs.
* Remove KMS related code after GA, reuse the implementation in azure-cli/acs.
Expand Down
40 changes: 0 additions & 40 deletions src/aks-preview/azext_aks_preview/managed_cluster_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2278,46 +2278,6 @@ def init_agentpool_decorator_context(self) -> None:
self.agentpool_context = self.agentpool_decorator.context
self.context.attach_agentpool_context(self.agentpool_context)

def check_raw_parameters(self):
"""Helper function to check whether any parameters are set.

Note: Overwritten in aks-preview to use different hard-coded error message.

If the values of all the parameters are the default values, the command execution will be terminated early and
raise a RequiredArgumentMissingError. Neither the request to fetch or update the ManagedCluster object will be
sent.

:return: None
"""
# exclude some irrelevant or mandatory parameters
excluded_keys = ("cmd", "client", "resource_group_name", "name")
# check whether the remaining parameters are set
# the default value None or False (and other empty values, like empty string) will be considered as not set
is_changed = any(
v for k, v in self.context.raw_param.items() if k not in excluded_keys)

# special cases
# some parameters support the use of empty string or dictionary to update/remove previously set values
is_default = (
self.context.get_cluster_autoscaler_profile() is None and
self.context.get_api_server_authorized_ip_ranges() is None and
self.context.get_nodepool_labels() is None
)

if not is_changed and is_default:
reconcilePrompt = 'no argument specified to update would you like to reconcile to current settings?'
if not prompt_y_n(reconcilePrompt, default="n"):
# Note: Uncomment the followings to automatically generate the error message.
option_names = [
'"{}"'.format(format_parameter_name_to_option_name(x))
for x in self.context.raw_param.keys()
if x not in excluded_keys
]
error_msg = "Please specify one or more of {}.".format(
" or ".join(option_names)
)
raise RequiredArgumentMissingError(error_msg)

def update_outbound_type_in_network_profile(self, mc: ManagedCluster) -> ManagedCluster:
"""Update outbound type of network profile for the ManagedCluster object.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4044,14 +4044,14 @@ def test_check_raw_parameters(self):
)
# fail on no updated parameter provided
with patch(
"azext_aks_preview.managed_cluster_decorator.prompt_y_n",
"azure.cli.command_modules.acs.managed_cluster_decorator.prompt_y_n",
return_value=False,
), self.assertRaises(RequiredArgumentMissingError):
dec_1.check_raw_parameters()

# unless user says they want to reconcile
with patch(
"azext_aks_preview.managed_cluster_decorator.prompt_y_n",
"azure.cli.command_modules.acs.managed_cluster_decorator.prompt_y_n",
return_value=True,
):
dec_1.check_raw_parameters()
Expand Down Expand Up @@ -5637,7 +5637,10 @@ def test_update_mc_profile_preview(self):
with patch(
"azure.cli.command_modules.acs.managed_cluster_decorator.get_rg_location",
return_value="test_location",
), patch("azure.cli.command_modules.acs.managed_cluster_decorator.Profile", return_value=mock_profile,), patch(
), patch(
"azure.cli.command_modules.acs.managed_cluster_decorator.Profile",
return_value=mock_profile,
), patch(
"azext_aks_preview.managed_cluster_decorator.AKSPreviewManagedClusterUpdateDecorator.check_raw_parameters",
return_value=True,
), patch.object(
Expand Down