@@ -460,10 +460,32 @@ def list_environments(self):
460460 data .append (row )
461461 self .print (data , ignore_silent = True )
462462
463+ # temporary fix till the new API is updated to return `profileEnvironmentProperties`
464+ def _get_missing_env_properties (
465+ self , app_id : str , app_type : str , env_id : str , profile_id : str , from_cache_command : bool
466+ ) -> dict :
467+ if app_type .lower () == 'kubernetes' and (from_cache_command or self .config .auto_refresh_kube_config ()):
468+ if not self .listed_profiles :
469+ self .listed_profiles = self .b .my_access .list_profiles ()
470+ return next (
471+ (
472+ env ['profileEnvironmentProperties' ]
473+ for app in self .listed_profiles
474+ if app ['appContainerId' ] == app_id
475+ for profile in app .get ('profiles' , [])
476+ if profile ['profileId' ] == profile_id
477+ for env in profile .get ('environments' , [])
478+ if env ['environmentId' ] == env_id
479+ ),
480+ {},
481+ )
482+ return {}
483+
463484 def _set_available_profiles (self , from_cache_command = False , profile_type : Optional [str ] = None ):
464485 if not self .available_profiles :
465486 data = []
466487 if not profile_type or profile_type == 'my-access' :
488+ self .listed_profiles = None
467489 access_limit = int (self .config .my_access_retrieval_limit )
468490 increase = 0
469491 while (access_data := self .b .my_access .list (size = access_limit + increase ))['count' ] > len (
@@ -496,7 +518,10 @@ def _set_available_profiles(self, from_cache_command=False, profile_type: Option
496518 'profile_allows_programmatic' : app .get ('programmaticAccess' , False ),
497519 'profile_description' : profile ['papDescription' ],
498520 '2_part_profile_format_allowed' : app ['supportsMultipleProfilesCheckoutConsole' ],
499- 'env_properties' : env .get ('profileEnvironmentProperties' , {}),
521+ 'env_properties' : env ['profileEnvironmentProperties' ]
522+ or self ._get_missing_env_properties (
523+ app_id , app ['catalogAppName' ], env_id , profile_id , from_cache_command
524+ ),
500525 }
501526 if row not in access_output :
502527 access_output .append (row )
@@ -542,7 +567,7 @@ def construct_kube_config(self, from_cache_command=False):
542567
543568 profiles = []
544569 for p in self .available_profiles :
545- if p ['app_type' ].lower () == 'kubernetes' :
570+ if p ['app_type' ].lower () == 'kubernetes' and p [ 'env_properties' ] :
546571 props = p ['env_properties' ]
547572 url = props .get ('apiServerUrl' )
548573 cert = props .get ('certificateAuthorityData' )
0 commit comments