Skip to content

Commit

Permalink
review: Document raised ApiError exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
kimwnasptd committed Jan 23, 2025
1 parent 67806d4 commit 367bc26
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/profiles_management/create_or_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ def create_or_update_profiles(
should exist in the cluster.
Raises:
ApiError: From lightkube if an error occurred while trying to create or delete
Profiles, RoleBindings or AuthorizationPolicies.
InvalidKfamAnnotationsError: If a RoleBinding or AuthorizationPolicy does not have
KFAM valid annotations.
"""
Expand Down
11 changes: 11 additions & 0 deletions src/profiles_management/helpers/kfam.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,16 @@ def delete_rolebindings_not_matching_profile_contributors(
) -> None:
"""Delete RoleBindings in the cluster that doesn't match Contributors in PMR Profile.
The function will be handling 404 errors, in case the RoleBinding doesn't exist in the
cluster.
Args:
client: The lightkube client to use.
profile: The PMR Profile to create RoleBindings based on its Contributors.
Raises:
ApiError: From lightkube if something unexpected occurred while deleting the
resources.
"""
existing_rolebindings = list_contributor_rolebindings(client, profile.name)
role_bindings_to_delete = []
Expand Down Expand Up @@ -284,6 +291,10 @@ def create_rolebindings_for_profile_contributors(
profile: The PMR to iterate over its Contributors.
existing_rolebindings: List of existing RoleBindings, to avoid doing redundant
API requests
Raises:
ApiError: From lightkube if there was an error while trying to create the
RoleBindings.
"""
existing_rolebindings = list_contributor_rolebindings(client, profile.name)
existing_contributor_roles = kfam_resources_list_to_roles_dict(existing_rolebindings)
Expand Down

0 comments on commit 367bc26

Please sign in to comment.