-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Add bucket-level IAM samples
#919
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
policy = bucket.get_iam_policy() | ||
|
||
for role in policy: | ||
members = policy[role] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why iterate over the keys and then do a dictionary lookup, instead of iterating over key, value using items()?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it's not a dictionary, see https://github.com/GoogleCloudPlatform/google-cloud-python/blob/master/core/google/cloud/iam.py#L64
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, ick.
If beginners like me are likely to read this code, maybe adding a comment about that here would prevent confusion. Up to you though, I don't have a lot of context yet.
storage/cloud-client/iam.py
Outdated
bucket.set_iam_policy(policy) | ||
|
||
print('Removed {} with role {} from {}.'.format( | ||
role, member, bucket_name)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should the order be 'member, role, bucket_name' instead ?
storage/cloud-client/iam.py
Outdated
bucket.set_iam_policy(policy) | ||
|
||
print('Added {} with role {} to {}.'.format( | ||
role, member, bucket_name)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should the order be 'member, role, bucket_name' instead ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch.
Failures unrelated (and reported to client library team). Merging. |
No description provided.