@@ -1985,6 +1985,71 @@ def get_custom_ca_trust_certificates(self) -> Union[List[bytes], None]:
19851985 )
19861986 return certs
19871987
1988+ def _get_enable_run_command (self , enable_validation : bool = False ) -> bool :
1989+ """Internal function to obtain the value of enable_run_command.
1990+ :return: bool
1991+ """
1992+ enable_run_command = self .raw_param .get ("enable_run_command" )
1993+
1994+ # In create mode, try to read the property value corresponding to the parameter from the `mc` object.
1995+ if self .decorator_mode == DecoratorMode .CREATE :
1996+ if (
1997+ self .mc and
1998+ hasattr (self .mc , "api_server_access_profile" ) and # backward compatibility
1999+ self .mc .api_server_access_profile and
2000+ self .mc .api_server_access_profile .disable_run_command is not None
2001+ ):
2002+ enable_run_command = not self .mc .api_server_access_profile .disable_run_command
2003+
2004+ # validation
2005+ if enable_validation :
2006+ if enable_run_command and self ._get_disable_run_command (enable_validation = False ):
2007+ raise MutuallyExclusiveArgumentError (
2008+ "Cannot specify --enable-run-command and --disable-run-command at the same time."
2009+ )
2010+
2011+ return enable_run_command
2012+
2013+ def get_enable_run_command (self ) -> bool :
2014+ """Obtain the value of enable_run_command.
2015+ This function will verify the parameter by default. If both enable_run_command and disable_run_command are
2016+ specified, raise a MutuallyExclusiveArgumentError.
2017+ :return: bool
2018+ """
2019+ return self ._get_enable_run_command (enable_validation = True )
2020+
2021+ def _get_disable_run_command (self , enable_validation : bool = False ) -> bool :
2022+ """Internal function to obtain the value of disable_run_command.
2023+ :return: bool
2024+ """
2025+ disable_run_command = self .raw_param .get ("disable_run_command" )
2026+
2027+ # In create mode, try to read the property value corresponding to the parameter from the `mc` object.
2028+ if self .decorator_mode == DecoratorMode .CREATE :
2029+ if (
2030+ self .mc and
2031+ hasattr (self .mc , "api_server_access_profile" ) and # backward compatibility
2032+ self .mc .api_server_access_profile and
2033+ self .mc .api_server_access_profile .disable_run_command is not None
2034+ ):
2035+ disable_run_command = self .mc .api_server_access_profile .disable_run_command
2036+
2037+ # validation
2038+ if enable_validation :
2039+ if disable_run_command and self ._get_enable_run_command (enable_validation = False ):
2040+ raise MutuallyExclusiveArgumentError (
2041+ "Cannot specify --enable-run-command and --disable-run-command at the same time."
2042+ )
2043+ return disable_run_command
2044+
2045+ def get_disable_run_command (self ) -> bool :
2046+ """Obtain the value of disable_run_command.
2047+ This function will verify the parameter by default. If both enable_run_command and disable_run_command
2048+ are specified, raise a MutuallyExclusiveArgumentError.
2049+ :return: bool
2050+ """
2051+ return self ._get_disable_run_command (enable_validation = True )
2052+
19882053 def _get_enable_azure_monitor_metrics (self , enable_validation : bool = False ) -> bool :
19892054 """Internal function to obtain the value of enable_azure_monitor_metrics.
19902055 This function supports the option of enable_validation. When enabled, if both enable_azure_monitor_metrics and
@@ -3035,6 +3100,26 @@ def set_up_network_profile(self, mc: ManagedCluster) -> ManagedCluster:
30353100 network_profile .advanced_networking = acns
30363101 return mc
30373102
3103+ def set_up_run_command (self , mc : ManagedCluster ) -> ManagedCluster :
3104+ """Set up run command for the ManagedCluster object.
3105+ :return: the ManagedCluster object
3106+ """
3107+ if hasattr (super (), 'set_up_run_command' ):
3108+ return super ().set_up_run_command (mc )
3109+
3110+ self ._ensure_mc (mc )
3111+
3112+ disable_run_command = self .context .get_disable_run_command ()
3113+ if disable_run_command :
3114+ if mc .api_server_access_profile is None :
3115+ mc .api_server_access_profile = self .models .ManagedClusterAPIServerAccessProfile (
3116+ disable_run_command = True
3117+ )
3118+ else :
3119+ mc .api_server_access_profile .disable_run_command = True
3120+
3121+ return mc
3122+
30383123 def set_up_api_server_access_profile (self , mc : ManagedCluster ) -> ManagedCluster :
30393124 """Set up apiserverAccessProfile enableVnetIntegration and subnetId for the ManagedCluster object.
30403125
@@ -3670,6 +3755,8 @@ def construct_mc_profile_preview(self, bypass_restore_defaults: bool = False) ->
36703755 mc = self .set_up_kube_proxy_config (mc )
36713756 # set up custom ca trust certificates
36723757 mc = self .set_up_custom_ca_trust_certificates (mc )
3758+ # set up run command
3759+ mc = self .set_up_run_command (mc )
36733760 # set up node resource group profile
36743761 mc = self .set_up_node_resource_group_profile (mc )
36753762 # set up auto upgrade profile
@@ -4732,6 +4819,35 @@ def update_custom_ca_trust_certificates(self, mc: ManagedCluster) -> ManagedClus
47324819
47334820 return mc
47344821
4822+ def update_run_command (self , mc : ManagedCluster ) -> ManagedCluster :
4823+ """Update run command for the ManagedCluster object.
4824+ :return: the ManagedCluster object
4825+ """
4826+ if hasattr (super (), 'update_run_command' ):
4827+ return super ().update_run_command (mc )
4828+
4829+ self ._ensure_mc (mc )
4830+
4831+ enable_run_command = self .context .get_enable_run_command ()
4832+ disable_run_command = self .context .get_disable_run_command ()
4833+ if enable_run_command or disable_run_command :
4834+ if mc .api_server_access_profile is None :
4835+ mc .api_server_access_profile = self .models .ManagedClusterAPIServerAccessProfile (
4836+ disable_run_command = (
4837+ not enable_run_command
4838+ if enable_run_command or disable_run_command
4839+ else None
4840+ )
4841+ )
4842+ else :
4843+ mc .api_server_access_profile .disable_run_command = (
4844+ not enable_run_command
4845+ if enable_run_command or disable_run_command
4846+ else None
4847+ )
4848+
4849+ return mc
4850+
47354851 def update_azure_monitor_profile (self , mc : ManagedCluster ) -> ManagedCluster :
47364852 """Update azure monitor profile for the ManagedCluster object.
47374853 :return: the ManagedCluster object
@@ -5466,6 +5582,8 @@ def update_mc_profile_preview(self) -> ManagedCluster:
54665582 mc = self .update_kube_proxy_config (mc )
54675583 # update custom ca trust certificates
54685584 mc = self .update_custom_ca_trust_certificates (mc )
5585+ # update run command
5586+ mc = self .update_run_command (mc )
54695587 # update node resource group profile
54705588 mc = self .update_node_resource_group_profile (mc )
54715589 # update auto upgrade profile
0 commit comments