You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2020/03/15 21:35:34 UTC

[GitHub] [airflow] OmairK opened a new pull request #7733: [AIRFLOW-4175] S3Hook load_file should support ACL policy paramete

OmairK opened a new pull request #7733: [AIRFLOW-4175] S3Hook load_file should support ACL policy paramete
URL: https://github.com/apache/airflow/pull/7733
 
 
   		 - Added acl_policy parameter to all the S3Hook.load_*() and S3Hook.copy_object() function
   		 - Added unittest to test the response permissions when the policy is passed
   		 - Updated the docstring of the function
   
   Co-authored-by: retornam <re...@users.noreply.github.com>
   
   ---
   Issue link: WILL BE INSERTED BY [boring-cyborg](https://github.com/kaxil/boring-cyborg)
   
   Make sure to mark the boxes below before creating PR: [x]
   
   - [x] Description above provides context of the change
   - [x] Commit message/PR title starts with `[AIRFLOW-NNNN]`. AIRFLOW-NNNN = JIRA ID<sup>*</sup>
   - [x] Unit tests coverage for changes (not needed for documentation changes)
   - [x] Commits follow "[How to write a good git commit message](http://chris.beams.io/posts/git-commit/)"
   - [x] Relevant documentation is updated including usage instructions.
   - [x] I will engage committers as explained in [Contribution Workflow Example](https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst#contribution-workflow-example).
   
   <sup>*</sup> For document-only changes commit message can start with `[AIRFLOW-XXXX]`.
   
   ---
   In case of fundamental code change, Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvements+Proposals)) is needed.
   In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
   In case of backwards incompatible changes please leave a note in [UPDATING.md](https://github.com/apache/airflow/blob/master/UPDATING.md).
   Read the [Pull Request Guidelines](https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst#pull-request-guidelines) for more information.
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [airflow] potiuk merged pull request #7733: [AIRFLOW-4175] S3Hook load_file should support ACL policy paramete

Posted by GitBox <gi...@apache.org>.
potiuk merged pull request #7733: [AIRFLOW-4175] S3Hook load_file should support ACL policy paramete
URL: https://github.com/apache/airflow/pull/7733
 
 
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [airflow] OmairK commented on issue #7733: [AIRFLOW-4175] S3Hook load_file should support ACL policy paramete

Posted by GitBox <gi...@apache.org>.
OmairK commented on issue #7733: [AIRFLOW-4175] S3Hook load_file should support ACL policy paramete
URL: https://github.com/apache/airflow/pull/7733#issuecomment-599491519
 
 
   > @OmairK is Keith O'Brien your Jira username? I would like to assign it. Or you do. :)
   
   @feluelle my Jira username is OmairK

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [airflow] potiuk commented on issue #7733: [AIRFLOW-4175] S3Hook load_file should support ACL policy paramete

Posted by GitBox <gi...@apache.org>.
potiuk commented on issue #7733: [AIRFLOW-4175] S3Hook load_file should support ACL policy paramete
URL: https://github.com/apache/airflow/pull/7733#issuecomment-599594989
 
 
   Thanks @OmairK @retornam and @feluelle !

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [airflow] potiuk commented on a change in pull request #7733: [AIRFLOW-4175] S3Hook load_file should support ACL policy paramete

Posted by GitBox <gi...@apache.org>.
potiuk commented on a change in pull request #7733: [AIRFLOW-4175] S3Hook load_file should support ACL policy paramete
URL: https://github.com/apache/airflow/pull/7733#discussion_r392827374
 
 

 ##########
 File path: tests/providers/amazon/aws/hooks/test_s3.py
 ##########
 @@ -255,6 +284,31 @@ def test_load_file_gzip(self, s3_bucket):
             resource = boto3.resource('s3').Object(s3_bucket, 'my_key')  # pylint: disable=no-member
             assert gz.decompress(resource.get()['Body'].read()) == b'Content'
 
+    def test_load_file_acl(self, s3_bucket):
+        hook = S3Hook()
+        with tempfile.NamedTemporaryFile() as temp_file:
+            temp_file.write(b"Content")
+            temp_file.seek(0)
+            hook.load_file(temp_file, "my_key", s3_bucket, gzip=True,
+                           acl_policy='public-read')
+            response = boto3.client('s3').get_object_acl(Bucket=s3_bucket,
+                                                         Key="my_key",
+                                                         RequestPayer='requester')  # pylint: disable=no-member # noqa: E501 # pylint: disable=C0301
+            assert ((response['Grants'][1]['Permission'] == 'READ') and
+                    (response['Grants'][0]['Permission'] == 'FULL_CONTROL'))
+
+    def test_copy_object_acl(self, s3_bucket):
+        hook = S3Hook()
+        with tempfile.NamedTemporaryFile() as temp_file:
+            temp_file.write(b"Content")
+            temp_file.seek(0)
+            hook.load_file_obj(temp_file, "my_key", s3_bucket)
+            hook.copy_object("my_key", "my_key", s3_bucket, s3_bucket)
+            response = boto3.client('s3').get_object_acl(Bucket=s3_bucket,
+                                                         Key="my_key",
+                                                         RequestPayer='requester')  # pylint: disable=no-member # noqa: E501 # pylint: disable=C0301
+            assert response['Grants'][0]['Permission'] == 'FULL_CONTROL'
 
 Review comment:
   One small thing  - can you please check there are no more permissions here?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [airflow] feluelle commented on issue #7733: [AIRFLOW-4175] S3Hook load_file should support ACL policy paramete

Posted by GitBox <gi...@apache.org>.
feluelle commented on issue #7733: [AIRFLOW-4175] S3Hook load_file should support ACL policy paramete
URL: https://github.com/apache/airflow/pull/7733#issuecomment-599452717
 
 
   @OmairK is Keith O'Brien your Jira username? I would like to assign it. Or you do. :)

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services