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

Add S3 storage service #144

Merged
merged 5 commits into from Dec 11, 2018
Merged

Add S3 storage service #144

merged 5 commits into from Dec 11, 2018

Conversation

LordMike
Copy link
Contributor

@LordMike LordMike commented Dec 2, 2018

(do not merge)

What does this PR do?

Implements an S3 storage service

Closes Issue(s)

Fixes #136

Motivation

If we deploy BaGet, we'll need S3 storage support :)

Additional Notes

This code has not been tested, yet. I'd like some feedback before proceeding. It's basically a copy off of the Azure project, with the search removed. I've replicated the configuration validation methods etc.

@LordMike LordMike changed the title WIP: Add S3 storage service [WIP] Add S3 storage service Dec 2, 2018
@LordMike
Copy link
Contributor Author

LordMike commented Dec 2, 2018

@loic-sharma I have a few thoughts and questions.

Shouldn't the storage services be simpler than this?

I would imagine that it would be possible to have a storage service inteface that implements the following:

  • Get(string path)
  • GetDownloadUrl(string path)
  • Put(string path, Stream content, string contentType)
  • Delete(string path)

Then a service could be built around this, that exposes the Nuspec/Package/Readme specifics. All storage services would be shielded from new package types (.snupkg), and services could expose new features without breaking implementations.

Adding the GetDownloadUrl() is useful for redirections, see #25. S3 would provide pre-signed urls (or whatever it needs to provie). Azure would do the same.

Is it necessary to add all storage implementations in the web project?

It seems odd to me to add all services, and then finally "remap" one service by adding it as the intended interface. Wouldn't it be better to have the wanted service register itself as the intended interface directly?

Why put the storage clients in the DI framework?

This is more of a preference thing: Why add the Azure Blobs-specific client to the DI, only to pull it out and give it to one specific implementation? It's not like it can be exchanged (no use of interfaces :P) .. so why not create the Azure Blobs client within BlobPackageStorageService (and the AmazonS3Client in S3StorageService for S3)?

@LordMike
Copy link
Contributor Author

LordMike commented Dec 2, 2018

Note: I did register the services in the web project, but didn't commit it because I missed it -- I'm seeing a lot of newline changes which I'm trying to figure out.

@loic-sharma
Copy link
Owner

@LordMike great suggestions. I went ahead and opened a PR that addresses your concerns: #145. Please let me know what you think! 😄

loic-sharma added a commit that referenced this pull request Dec 4, 2018
Adds a new interface, `IStorageService` for low level storage APIs. This interface is implemented by `FileStorageService` and `BlobStorageService` for Azure. All package content operations are now managed by `PackageStorageService` regardless of the low-level storage implementation. Addresses #144 (comment)
@LordMike LordMike force-pushed the feature/s3 branch 3 times, most recently from 8c34665 to e9a6703 Compare December 4, 2018 22:28
@LordMike
Copy link
Contributor Author

LordMike commented Dec 4, 2018

@loic-sharma I've updated this implementation for #145, it's been tested and can successfully upload, download packages.

I have not tested the deletes or get-uri, as BaGet does not currently expose those.

@LordMike LordMike changed the title [WIP] Add S3 storage service Add S3 storage service Dec 4, 2018
@loic-sharma
Copy link
Owner

loic-sharma commented Dec 4, 2018

Looks good! I left some minor comments, please address them and I'll merge these changes in :)

@LordMike
Copy link
Contributor Author

LordMike commented Dec 5, 2018

@loic-sharma I've just noticed ValidateOptions is never called. Neither is Azure's version.

Where should this be used?

@loic-sharma
Copy link
Owner

loic-sharma commented Dec 5, 2018

@loic-sharma I've just noticed ValidateOptions is never called. Neither is Azure's version.

Oh whoops, good catch! I improved BaGet's configuration validation in #147. You should now register your configuration using services.ConfigureAndValidate<MyOptions>(...) or services.ConfigureAndValidateSection<MyOptions>(...). This will verify that the configs' values match the option's annotations. For example, the BlobStorageOptions are configured here.

@LordMike
Copy link
Contributor Author

LordMike commented Dec 5, 2018

@loic-sharma updated.

@LordMike
Copy link
Contributor Author

LordMike commented Dec 5, 2018

I also changed a few ConfigureAndValidate<T>() to ConfigureAndValidateSection<T>()

@loic-sharma
Copy link
Owner

Could you rebase this off of the latest master? It's a little tricky to review right now with the line ending changes. Thanks!

@LordMike
Copy link
Contributor Author

LordMike commented Dec 6, 2018

I wasn't able to rebase, but I did copy all the changes to a new commit.

@loic-sharma
Copy link
Owner

This is looking good. I left some final feedback, once that's addressed I'll merge this in :)

@loic-sharma loic-sharma merged commit dfbd66e into loic-sharma:master Dec 11, 2018
@loic-sharma
Copy link
Owner

Thank you @LordMike for the great work! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants