Skip to content

Apply code review suggestions to replace "member" with "principal" in additional places#13071

Merged
melaniedejong merged 2 commits intomelaniedejong-patch-1from
melaniedejong-patch-2
Jan 16, 2025
Merged

Apply code review suggestions to replace "member" with "principal" in additional places#13071
melaniedejong merged 2 commits intomelaniedejong-patch-1from
melaniedejong-patch-2

Conversation

@melaniedejong
Copy link
Collaborator

No description provided.

Per code review suggestions, replace additional instances of "member" with "principal"
@melaniedejong melaniedejong requested review from a team as code owners January 16, 2025 23:39
@product-auto-label product-auto-label bot added samples Issues that are directly related to samples. api: iam Issues related to the Identity and Access Management API. labels Jan 16, 2025
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @melaniedejong and reviewers,

I'm currently reviewing this pull request and will provide my feedback shortly. In the meantime, here's a summary to help everyone quickly understand the changes:

This pull request addresses code review suggestions by replacing instances of the term "member" with "principal" for improved clarity and consistency. The changes are focused on enhancing the accuracy of the terminology used in relation to IAM roles and permissions.

Here's a breakdown of the changes:

  • Files Modified:

    • iam/cloud-client/snippets/modify_policy_add_member.py
      • The parameter member in the modify_policy_add_member function was renamed to principal (lines 21-22, 55). The function's docstring was also updated to reflect this change (lines 28-29).
    • iam/cloud-client/snippets/modify_policy_remove_member.py
      • The parameter member in the modify_policy_remove_member function was renamed to principal (lines 21-22, 55). The function's docstring was updated (lines 28-29). The line removing the member from the list was also updated to use principal instead of member (line 38).
  • Overall Intent: To improve the accuracy and consistency of terminology related to IAM principals within the code snippets.

This small change makes a big difference,
In clarity and precision, it's a win.
No more confusion, a smoother flow,
Code's elegance, now starts to show.

@melaniedejong melaniedejong merged commit f9e3efc into melaniedejong-patch-1 Jan 16, 2025
3 checks passed
@melaniedejong melaniedejong deleted the melaniedejong-patch-2 branch January 16, 2025 23:39
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pull request replaces instances of "member" with "principal" in modify_policy_add_member.py and modify_policy_remove_member.py files, which improves clarity and consistency with IAM terminology. However, there's a minor issue in modify_policy_add_member.py where the variable principal is not defined in the if __name__ == "__main__" block. Also, the variable member is still used in modify_policy_remove_member.py.

member = f"serviceAccount:test-service-account@{project_id}.iam.gserviceaccount.com"

modify_policy_add_member(project_id, role, member)
modify_policy_add_member(project_id, role, principal)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The variable principal is not defined. Should this be using the member variable defined on line 53? Or should we rename that variable to principal to match the function parameter?

Suggested change
modify_policy_add_member(project_id, role, principal)
modify_policy_add_member(project_id, role, member)

Comment on lines 37 to +38
if member in bind.members:
bind.members.remove(member)
bind.members.remove(principal)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The variable member is still used here. To maintain consistency, should this be changed to principal to match the function parameter and docstring?

Suggested change
if member in bind.members:
bind.members.remove(member)
bind.members.remove(principal)
if principal in bind.members:
bind.members.remove(principal)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: iam Issues related to the Identity and Access Management API. samples Issues that are directly related to samples.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants