-
Notifications
You must be signed in to change notification settings - Fork 44
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
Flag support. (Implementation 2) #30
Conversation
Alternate implementation to #29. |
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.
Really nice enhancement! After staring at both for a while I definitely prefer this to the chain of if's.
cloudaux/orchestration/aws/s3.py
Outdated
if flags & entry['flag']: | ||
result.update({entry['key']: entry['method'](bucket_name, **conn)}) | ||
|
||
if flags & FLAGS.GRANTS: |
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.
Any way to get this to use the same approach as rest of flags?
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.
See the comment for the rtv_ix
. It would be nice to use the same approach. Maybe you can help figure out how to do it.
cloudaux/orchestration/aws/s3.py
Outdated
if type(key) not in [list, tuple]: | ||
key_list = [key] | ||
for idx in xrange(len(flag_list)): | ||
cls.r.append(dict(flag=flag_list[idx], key=key_list[idx], method=fn, rtv_ix=idx)) |
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.
Maybe add a comment as simple as an example line here just as a shortcut to future reviewers?
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.
What's rtv_ix used for here?
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 point - I initially wrote the FlagRegistry class to try and handle the get_grants()
method, which is unique in that it has multiple return values that should get mapped to different fields in the return dictionary.
+# @FlagRegistry.register(
+# flag=(FLAGS.GRANTS, FLAGS.GRANT_REFERENCES, FLAGS.OWNER),
+# key=('grants', 'grant_references', 'owner'))
+def get_grants(bucket_name, include_owner=True, **conn):
The rtv_ix
was suppose to indicate the index of the return value. However, I kind of abandoned the idea of having FlagRegistry support these more complex interactions. I don't want to call the method three times.
cloudaux/orchestration/aws/s3.py
Outdated
import logging | ||
import json | ||
|
||
|
||
logger = logging.getLogger('cloudaux') | ||
|
||
|
||
def get_grants(bucket_name, include_owner=False, **conn): | ||
FLAGS=Bunch( |
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.
Is Bunch
okay or should we use something else.
Can IDE's autocomplete on bunch?
Things to consider:
|
|
@supertom - I think this is about ready. I added flags to all three GCP technologies. |
Fix that before merge. Run the security_monkey tests and watchers with this version and ensure things work as expected. |
Need to preserve this behavior. |
…eturn values is required.
…rrecting include_created behavior for backwards compatibility.
I fixed the Test on SM before merging. |
Tested on SM. Works great. Spend some time making sure the GCP services work as expected and then we're good to go. |
Just get WEBSITE and POLICY:
Result:
Get the BASE as well:
Result: