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

Decouple s3 #688

Merged
merged 7 commits into from
Oct 5, 2017
Merged

Decouple s3 #688

merged 7 commits into from
Oct 5, 2017

Conversation

kmcrawford
Copy link
Member

No description provided.

options.storage.adapterType &&
!options.storage.adapter
) {
switch (options.storage.adapterType) {
Copy link
Contributor

@nickbalestra nickbalestra Oct 4, 2017

Choose a reason for hiding this comment

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

I think we could simply check for options.s3 here without the need for an adapterType.
In the case that s3 is not avail, you will need to declaratively pass an adapter and options and rely on the new API. What you think?

Copy link
Member Author

Choose a reason for hiding this comment

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

My main reason for using adapterType was the the user would have to specify the following:

adapter: require('oc/src/domain/registry/s3')

It just didn't seem elegant to have people reach down into the source to pull back config info. With that I thought about removing the adapter from the config, but I also liked how I could add my own if I had a proprietary internal datastore that I didn't want to have in open source land.

Copy link
Contributor

@nickbalestra nickbalestra Oct 4, 2017

Choose a reason for hiding this comment

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

Ok, I see what you trying to do.
So, if we are using adapterType only for the default adapter (s3) to avoid people to reach down to get the default adapter we could just make it optional..

  • if you don't specify an adapter it will use the s3 one that come with oc
  • else you need to declare your own adapter.

This way we don't add an option that is actually only been used only for the default (s3), and we simply sanitize the default adapter. What you recon?

Copy link
Contributor

@nickbalestra nickbalestra left a comment

Choose a reason for hiding this comment

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

Great job, thank you 💯 for this!
I think that overall look pretty solid, I just added some questions around the new API, let me know what you think

!options.storage.adapter
) {
switch (options.storage.adapterType) {
case 's3':
Copy link
Contributor

Choose a reason for hiding this comment

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

As mentioned above this will avoid to have a switch statement on the adapterType, and just setup a default in case for s3 config (legacy) overridable with the new API.

const options = !conf.local && conf.storage.options;
const repositorySource = conf.local
? 'local repository'
: conf.storage.adapterType + ' cdn';
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps here we could have the adapter exposing his own name instead ?
maybe something like conf.storage.adapter.type?

Copy link
Member Author

Choose a reason for hiding this comment

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

Funny I had it that way first..., but as stated before I wasn't a fan of
adapter: require('oc/src/domain/registry/s3')

Copy link
Contributor

@nickbalestra nickbalestra Oct 4, 2017

Choose a reason for hiding this comment

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

I agree with you and I think we can avoid the user to set adapter: require('oc/src/domain/registry/s3') as that will be the default, so you'll only pass an adapter if you want to override that.

const settings = require('../../resources/settings');
const strings = require('../../resources');
const validator = require('./validators');
const versionHandler = require('./version-handler');

module.exports = function(conf) {
const cdn = !conf.local && new S3(conf);
const repositorySource = conf.local ? 'local repository' : 's3 cdn';
const cdn = !conf.local && new conf.storage.adapter(conf.storage.options);
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice I like that now we can just pass the options to its own adapter 👍

Copy link
Contributor

@nickbalestra nickbalestra left a comment

Choose a reason for hiding this comment

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

This is awesome! Thank you @kmcrawford 🎉🎉🎉
@kmcrawford if it ain't too much of a last request could you remove the package-lock.json from the PR, we are still thinking about adding those...

I'm going to approve this, @matteofigus as I'll be traveling tomorrow could you please merge & publish this?

Next steps:

@matteofigus matteofigus merged commit e7ccd00 into opencomponents:master Oct 5, 2017
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.

3 participants