diff --git a/CHANGELOG.md b/CHANGELOG.md index 4252d78..94bb755 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,29 @@ > As of v1.4.0, release candidates will be published in an effort to get new features out faster while still allowing > time for full QA testing before moving the release candidate to a full release. +## v2.1.1 [2025-03-13] + +__What's New:__ + +* None + +__Enhancements:__ + +* None + +__Bug Fixes:__ + +* Skip `construct_kube_config` if `env_properties` is missing. +* Retrieve `profileEnvironmentProperties` from `my_access.list_profiles` if the new API doesn't return the data. + +__Dependencies:__ + +* None + +__Other:__ + +* None + ## v2.1.0 [2025-03-10] __What's New:__ diff --git a/src/pybritive/__init__.py b/src/pybritive/__init__.py index a33997d..55fa725 100644 --- a/src/pybritive/__init__.py +++ b/src/pybritive/__init__.py @@ -1 +1 @@ -__version__ = '2.1.0' +__version__ = '2.1.1' diff --git a/src/pybritive/britive_cli.py b/src/pybritive/britive_cli.py index d837c38..733950f 100644 --- a/src/pybritive/britive_cli.py +++ b/src/pybritive/britive_cli.py @@ -460,10 +460,32 @@ def list_environments(self): data.append(row) self.print(data, ignore_silent=True) + # temporary fix till the new API is updated to return `profileEnvironmentProperties` + def _get_missing_env_properties( + self, app_id: str, app_type: str, env_id: str, profile_id: str, from_cache_command: bool + ) -> dict: + if app_type.lower() == 'kubernetes' and (from_cache_command or self.config.auto_refresh_kube_config()): + if not self.listed_profiles: + self.listed_profiles = self.b.my_access.list_profiles() + return next( + ( + env['profileEnvironmentProperties'] + for app in self.listed_profiles + if app['appContainerId'] == app_id + for profile in app.get('profiles', []) + if profile['profileId'] == profile_id + for env in profile.get('environments', []) + if env['environmentId'] == env_id + ), + {}, + ) + return {} + def _set_available_profiles(self, from_cache_command=False, profile_type: Optional[str] = None): if not self.available_profiles: data = [] if not profile_type or profile_type == 'my-access': + self.listed_profiles = None access_limit = int(self.config.my_access_retrieval_limit) increase = 0 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 'profile_allows_programmatic': app.get('programmaticAccess', False), 'profile_description': profile['papDescription'], '2_part_profile_format_allowed': app['supportsMultipleProfilesCheckoutConsole'], - 'env_properties': env.get('profileEnvironmentProperties', {}), + 'env_properties': env['profileEnvironmentProperties'] + or self._get_missing_env_properties( + app_id, app['catalogAppName'], env_id, profile_id, from_cache_command + ), } if row not in access_output: access_output.append(row) @@ -542,7 +567,7 @@ def construct_kube_config(self, from_cache_command=False): profiles = [] for p in self.available_profiles: - if p['app_type'].lower() == 'kubernetes': + if p['app_type'].lower() == 'kubernetes' and p['env_properties']: props = p['env_properties'] url = props.get('apiServerUrl') cert = props.get('certificateAuthorityData')