Skip to content
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

Functionality to create storage buckets in GCP and AWS #291

Merged
merged 14 commits into from
Apr 26, 2021
Merged

Functionality to create storage buckets in GCP and AWS #291

merged 14 commits into from
Apr 26, 2021

Conversation

Fryyyyy
Copy link
Collaborator

@Fryyyyy Fryyyyy commented Apr 19, 2021

As part of the work for #135 - first we need to be able to create buckets.

@codecov-commenter
Copy link

codecov-commenter commented Apr 19, 2021

Codecov Report

Merging #291 (551f8c6) into master (e4448c6) will increase coverage by 0.26%.
The diff coverage is 67.08%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #291      +/-   ##
==========================================
+ Coverage   65.39%   65.66%   +0.26%     
==========================================
  Files          14       32      +18     
  Lines         968     2222    +1254     
==========================================
+ Hits          633     1459     +826     
- Misses        335      763     +428     
Flag Coverage Δ
nosetests 65.66% <67.08%> (+0.26%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...cloudforensics/providers/azure/internal/network.py 24.52% <24.52%> (ø)
libcloudforensics/providers/gcp/forensics.py 34.78% <28.28%> (-30.22%) ⬇️
libcloudforensics/providers/aws/internal/kms.py 40.00% <40.00%> (ø)
...ibcloudforensics/providers/gcp/internal/compute.py 51.01% <45.94%> (-11.34%) ⬇️
libcloudforensics/providers/aws/forensics.py 56.16% <53.06%> (-13.61%) ⬇️
...cs/providers/gcp/internal/compute_base_resource.py 37.33% <54.28%> (+0.82%) ⬆️
libcloudforensics/providers/aws/internal/log.py 73.07% <55.55%> (-4.20%) ⬇️
libcloudforensics/providers/gcp/internal/common.py 56.89% <57.44%> (+0.57%) ⬆️
...bcloudforensics/providers/gcp/internal/function.py 40.54% <62.50%> (+8.28%) ⬆️
...loudforensics/providers/azure/internal/resource.py 65.38% <65.38%> (ø)
... and 41 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8184367...551f8c6. Read the comment docs.

@Fryyyyy
Copy link
Collaborator Author

Fryyyyy commented Apr 19, 2021

Not sure what's up with this current linting error ?

Copy link
Collaborator

@giovannt0 giovannt0 left a comment

Choose a reason for hiding this comment

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

Few nits, otherwise LGTM

ACL=acl,
CreateBucketConfiguration={
'LocationConstraint': region or self.aws_account.default_region
}) # type: Dict[str, Any]
Copy link
Collaborator

Choose a reason for hiding this comment

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

CreateBucketConfiguration={  # type: Dict[str, Any]
              'LocationConstraint': region or self.aws_account.default_region
          })

Should fix the mypy problem

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok

self,
name: str,
region: Optional[str] = None,
acl: Optional[str] = 'private') -> Dict[str, Any]:
Copy link
Collaborator

Choose a reason for hiding this comment

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

The Optional type hint can be removed here since it's assigned a default value.
In general, for named parameters that default to None, we use the Optional type hint. All other cases, we don't.

https://docs.aws.amazon.com/AmazonS3/latest/userguide/acl-overview.html#canned-acl # pylint: disable=line-too-long

Returns:
Dict: An API operation object an S3 bucket.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Typo/missing word(s) in the sentence?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

gcs_path: str,
user_project: Optional[str] = None) -> Dict[str, Any]:
def GetObjectMetadata(
self, gcs_path: str,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add a new line after self param

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

@@ -98,8 +98,7 @@ def GetObjectMetadata(self,
response = request.execute() # type: Dict[str, Any]
return response

def GetBucketACLs(self,
bucket: str,
def GetBucketACLs(self, bucket: str,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add a new line after self param

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

self,
bucket: str,
labels: Optional[Dict[str, str]] = None,
predefinedacl: Optional[str] = 'private',
Copy link
Collaborator

Choose a reason for hiding this comment

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

See comment above for the use of Optional
Same below

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

self,
name: str,
region: Optional[str] = None,
acl: Optional[str] = 'private') -> Dict[str, Any]:
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

https://docs.aws.amazon.com/AmazonS3/latest/userguide/acl-overview.html#canned-acl # pylint: disable=line-too-long

Returns:
Dict: An API operation object an S3 bucket.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

ACL=acl,
CreateBucketConfiguration={
'LocationConstraint': region or self.aws_account.default_region
}) # type: Dict[str, Any]
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok

gcs_path: str,
user_project: Optional[str] = None) -> Dict[str, Any]:
def GetObjectMetadata(
self, gcs_path: str,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

@@ -98,8 +98,7 @@ def GetObjectMetadata(self,
response = request.execute() # type: Dict[str, Any]
return response

def GetBucketACLs(self,
bucket: str,
def GetBucketACLs(self, bucket: str,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

self,
bucket: str,
labels: Optional[Dict[str, str]] = None,
predefinedacl: Optional[str] = 'private',
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

@Fryyyyy
Copy link
Collaborator Author

Fryyyyy commented Apr 21, 2021

:( still the mypy error, @giovannt0

@giovannt0
Copy link
Collaborator

@Fryyyyy this works locally:

bucket = client.create_bucket(
          Bucket=name,
          ACL=acl,
          CreateBucketConfiguration={
              'LocationConstraint': region or self.aws_account.default_region
          })  # type: Dict[str, Any]
      return bucket

libcloudforensics/providers/aws/internal/s3.py Outdated Show resolved Hide resolved
libcloudforensics/providers/aws/internal/s3.py Outdated Show resolved Hide resolved
libcloudforensics/providers/gcp/internal/storage.py Outdated Show resolved Hide resolved
libcloudforensics/providers/gcp/internal/storage.py Outdated Show resolved Hide resolved
libcloudforensics/providers/gcp/internal/storage.py Outdated Show resolved Hide resolved
tests/providers/aws/internal/test_s3.py Show resolved Hide resolved
tests/providers/gcp/internal/test_storage.py Show resolved Hide resolved
@tomchop tomchop self-requested a review April 26, 2021 12:13
@tomchop tomchop merged commit d15bc2a into google:master Apr 26, 2021
@Fryyyyy Fryyyyy deleted the create_storage branch April 27, 2021 00:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants