@@ -771,46 +771,46 @@ def __read_kv_from_kubernetes_configmap(
771771 Returns:
772772 list: List of KeyValue objects
773773 """
774- # try:
775- key_values = []
776- from azure .cli .command_modules .acs .custom import aks_runcommand
777- from azure .cli .command_modules .acs ._client_factory import cf_managed_clusters
774+ try :
775+ key_values = []
776+ from azure .cli .command_modules .acs .custom import aks_runcommand
777+ from azure .cli .command_modules .acs ._client_factory import cf_managed_clusters
778778
779- # Get the AKS client from the factory
780- cmd .cli_ctx .data ['subscription_id' ] = aks_cluster ["subscription" ]
781- cmd .cli_ctx .data ['safe_params' ] = None
782- aks_client = cf_managed_clusters (cmd .cli_ctx )
779+ # Get the AKS client from the factory
780+ cmd .cli_ctx .data ['subscription_id' ] = aks_cluster ["subscription" ]
781+ cmd .cli_ctx .data ['safe_params' ] = None
782+ aks_client = cf_managed_clusters (cmd .cli_ctx )
783783
784- # Command to get the ConfigMap and output it as JSON
785- command = f"kubectl get configmap { configmap_name } -n { namespace } -o json"
784+ # Command to get the ConfigMap and output it as JSON
785+ command = f"kubectl get configmap { configmap_name } -n { namespace } -o json"
786786
787- # Execute the command on the cluster
788- result = aks_runcommand (cmd , aks_client , aks_cluster ["resource_group" ], aks_cluster ["name" ], command_string = command )
787+ # Execute the command on the cluster
788+ result = aks_runcommand (cmd , aks_client , aks_cluster ["resource_group" ], aks_cluster ["name" ], command_string = command )
789789
790- if hasattr (result , 'logs' ) and result .logs :
791- if not hasattr (result , 'exit_code' ) or result .exit_code != 0 :
792- raise AzureResponseError (f"{ result .logs .strip ()} " )
790+ if hasattr (result , 'logs' ) and result .logs :
791+ if not hasattr (result , 'exit_code' ) or result .exit_code != 0 :
792+ raise AzureResponseError (f"{ result .logs .strip ()} " )
793793
794- try :
795- configmap_data = json .loads (result .logs )
794+ try :
795+ configmap_data = json .loads (result .logs )
796796
797- # Extract the data section which contains the key-value pairs
798- kvs = __extract_kv_from_configmap_data (
799- configmap_data , content_type , prefix_to_add , format_ , depth , separator )
797+ # Extract the data section which contains the key-value pairs
798+ kvs = __extract_kv_from_configmap_data (
799+ configmap_data , content_type , prefix_to_add , format_ , depth , separator )
800800
801- key_values .extend (kvs )
802- except json .JSONDecodeError :
803- raise ValidationError (
804- f"The result from ConfigMap { configmap_name } could not be parsed as valid JSON."
805- )
806- else :
807- raise AzureResponseError ("Unable to get the ConfigMap." )
801+ key_values .extend (kvs )
802+ except json .JSONDecodeError :
803+ raise ValidationError (
804+ f"The result from ConfigMap { configmap_name } could not be parsed as valid JSON."
805+ )
806+ else :
807+ raise AzureResponseError ("Unable to get the ConfigMap." )
808808
809- return key_values
810- # except Exception as exception:
811- # raise AzureInternalError(
812- # f"Failed to read key-values from ConfigMap '{configmap_name}' in namespace '{namespace}'.\n{str(exception)}"
813- # )
809+ return key_values
810+ except Exception as exception :
811+ raise AzureInternalError (
812+ f"Failed to read key-values from ConfigMap '{ configmap_name } ' in namespace '{ namespace } '.\n { str (exception )} "
813+ )
814814
815815
816816def __extract_kv_from_configmap_data (configmap_data , content_type , prefix_to_add = "" , format_ = None , depth = None , separator = None ):
0 commit comments