@@ -925,6 +925,71 @@ def get_custom_ca_trust_certificates(self) -> Union[List[bytes], None]:
925925 )
926926 return certs
927927
928+ def _get_enable_run_command (self , enable_validation : bool = False ) -> bool :
929+ """Internal function to obtain the value of enable_run_command.
930+ :return: bool
931+ """
932+ enable_run_command = self .raw_param .get ("enable_run_command" )
933+
934+ # In create mode, try to read the property value corresponding to the parameter from the `mc` object.
935+ if self .decorator_mode == DecoratorMode .CREATE :
936+ if (
937+ self .mc and
938+ hasattr (self .mc , "api_server_access_profile" ) and # backward compatibility
939+ self .mc .api_server_access_profile and
940+ self .mc .api_server_access_profile .disable_run_command is not None
941+ ):
942+ enable_run_command = not self .mc .api_server_access_profile .disable_run_command
943+
944+ # validation
945+ if enable_validation :
946+ if enable_run_command and self ._get_disable_run_command (enable_validation = False ):
947+ raise MutuallyExclusiveArgumentError (
948+ "Cannot specify --enable-run-command and --disable-run-command at the same time."
949+ )
950+
951+ return enable_run_command
952+
953+ def get_enable_run_command (self ) -> bool :
954+ """Obtain the value of enable_run_command.
955+ This function will verify the parameter by default. If both enable_run_command and disable_run_command are
956+ specified, raise a MutuallyExclusiveArgumentError.
957+ :return: bool
958+ """
959+ return self ._get_enable_run_command (enable_validation = True )
960+
961+ def _get_disable_run_command (self , enable_validation : bool = False ) -> bool :
962+ """Internal function to obtain the value of disable_run_command.
963+ :return: bool
964+ """
965+ disable_run_command = self .raw_param .get ("disable_run_command" )
966+
967+ # In create mode, try to read the property value corresponding to the parameter from the `mc` object.
968+ if self .decorator_mode == DecoratorMode .CREATE :
969+ if (
970+ self .mc and
971+ hasattr (self .mc , "api_server_access_profile" ) and # backward compatibility
972+ self .mc .api_server_access_profile and
973+ self .mc .api_server_access_profile .disable_run_command is not None
974+ ):
975+ disable_run_command = self .mc .api_server_access_profile .disable_run_command
976+
977+ # validation
978+ if enable_validation :
979+ if disable_run_command and self ._get_enable_run_command (enable_validation = False ):
980+ raise MutuallyExclusiveArgumentError (
981+ "Cannot specify --enable-run-command and --disable-run-command at the same time."
982+ )
983+ return disable_run_command
984+
985+ def get_disable_run_command (self ) -> bool :
986+ """Obtain the value of disable_run_command.
987+ This function will verify the parameter by default. If both enable_run_command and disable_run_command
988+ are specified, raise a MutuallyExclusiveArgumentError.
989+ :return: bool
990+ """
991+ return self ._get_disable_run_command (enable_validation = True )
992+
928993 def get_snapshot_controller (self ) -> Optional [ManagedClusterStorageProfileSnapshotController ]:
929994 """Obtain the value of storage_profile.snapshot_controller
930995
@@ -6492,6 +6557,23 @@ def set_up_custom_ca_trust_certificates(self, mc: ManagedCluster) -> ManagedClus
64926557
64936558 return mc
64946559
6560+ def set_up_run_command (self , mc : ManagedCluster ) -> ManagedCluster :
6561+ """Set up run command for the ManagedCluster object.
6562+ :return: the ManagedCluster object
6563+ """
6564+ self ._ensure_mc (mc )
6565+
6566+ disable_run_command = self .context .get_disable_run_command ()
6567+ if disable_run_command :
6568+ if mc .api_server_access_profile is None :
6569+ mc .api_server_access_profile = self .models .ManagedClusterAPIServerAccessProfile (
6570+ disable_run_command = True
6571+ )
6572+ else :
6573+ mc .api_server_access_profile .disable_run_command = True
6574+
6575+ return mc
6576+
64956577 def set_up_api_server_access_profile (self , mc : ManagedCluster ) -> ManagedCluster :
64966578 """Set up api server access profile and fqdn subdomain for the ManagedCluster object.
64976579
@@ -7004,7 +7086,8 @@ def construct_mc_profile_default(self, bypass_restore_defaults: bool = False) ->
70047086 mc = self .set_up_ingress_web_app_routing (mc )
70057087 # set up custom ca trust certificates
70067088 mc = self .set_up_custom_ca_trust_certificates (mc )
7007-
7089+ # set up run command
7090+ mc = self .set_up_run_command (mc )
70087091 # setup k8s support plan
70097092 mc = self .set_up_k8s_support_plan (mc )
70107093 # set up azure monitor metrics profile
@@ -8519,6 +8602,33 @@ def update_custom_ca_trust_certificates(self, mc: ManagedCluster) -> ManagedClus
85198602
85208603 return mc
85218604
8605+ def update_run_command (self , mc : ManagedCluster ) -> ManagedCluster :
8606+ """Update run command for the ManagedCluster object.
8607+
8608+ :return: the ManagedCluster object
8609+ """
8610+ self ._ensure_mc (mc )
8611+
8612+ enable_run_command = self .context .get_enable_run_command ()
8613+ disable_run_command = self .context .get_disable_run_command ()
8614+ if enable_run_command or disable_run_command :
8615+ if mc .api_server_access_profile is None :
8616+ mc .api_server_access_profile = self .models .ManagedClusterAPIServerAccessProfile (
8617+ disable_run_command = (
8618+ not enable_run_command
8619+ if enable_run_command or disable_run_command
8620+ else None
8621+ )
8622+ )
8623+ else :
8624+ mc .api_server_access_profile .disable_run_command = (
8625+ not enable_run_command
8626+ if enable_run_command or disable_run_command
8627+ else None
8628+ )
8629+
8630+ return mc
8631+
85228632 def update_azure_monitor_profile (self , mc : ManagedCluster ) -> ManagedCluster :
85238633 """Update azure monitor profile for the ManagedCluster object.
85248634 :return: the ManagedCluster object
@@ -9019,6 +9129,8 @@ def update_mc_profile_default(self) -> ManagedCluster:
90199129 mc = self .update_auto_upgrade_profile (mc )
90209130 # update custom ca trust certificates
90219131 mc = self .update_custom_ca_trust_certificates (mc )
9132+ # update run command
9133+ mc = self .update_run_command (mc )
90229134 # update identity
90239135 mc = self .update_identity (mc )
90249136 # update addon profiles
0 commit comments