diff --git a/src/aks-preview/HISTORY.rst b/src/aks-preview/HISTORY.rst index 8716b3f8c80..e54a730f6b1 100644 --- a/src/aks-preview/HISTORY.rst +++ b/src/aks-preview/HISTORY.rst @@ -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. diff --git a/src/aks-preview/azext_aks_preview/managed_cluster_decorator.py b/src/aks-preview/azext_aks_preview/managed_cluster_decorator.py index 6af9661125e..950a8e5b1ca 100644 --- a/src/aks-preview/azext_aks_preview/managed_cluster_decorator.py +++ b/src/aks-preview/azext_aks_preview/managed_cluster_decorator.py @@ -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. diff --git a/src/aks-preview/azext_aks_preview/tests/latest/test_managed_cluster_decorator.py b/src/aks-preview/azext_aks_preview/tests/latest/test_managed_cluster_decorator.py index 7077df3d63b..776e2b3f860 100644 --- a/src/aks-preview/azext_aks_preview/tests/latest/test_managed_cluster_decorator.py +++ b/src/aks-preview/azext_aks_preview/tests/latest/test_managed_cluster_decorator.py @@ -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() @@ -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(