-
-
Notifications
You must be signed in to change notification settings - Fork 87
Make S3Overrides accessible via E-Var or option AND tests #40
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
Conversation
Background: when using parse server with a config file there is no way to specify S3Override options. -This change doesn't affect the current method of passing s3overrides = backwards compatible. -s3overrides would now be accessible by via parse-server config file like this: "filesAdapter": { "module":"parse-server-s3-adapter", "options":{ "s3overrides": { "endpoint": {"protocol":"https:","host":"$FILEURL","port":443,"hostname":"<your NOT s3 url like minio>","pathname":"/","path":"/","href":"https://<your NOT s3 url like minio>/"}, "s3BucketEndpoint": false, ANY OTHER S3OVERRIDES GO HERE... }, "baseUrl": "https://<your url>", "directAccess": true, "accessKey": "<your access key>", "secretKey": "<your secret>", "bucket": "<your bucket>", "region": "" } } -OR in theory (I haven't tested) by Environmental variable like so: S3_OVERRIDES="{ "endpoint": {"protocol":"https:","host":"$FILEURL","port":443,"hostname":"$FILEURL","pathname":"/","path":"/","href":"https://$FILEURL/"}, "s3BucketEndpoint": false, ANY OTHER S3OVERRIDES GO HERE... }"
Make S3Overrides accessible via E-Var or option.
deleted data to see if that helps error
changed Key to see if this is the issue
isolating ACL
removed isolations variables
deleting extra space
added error handling to create bucket
bucket change
only mark bucket as yes if it exists
caps
added logging of final override options
this ends up being a breaking change. reverting
@acinader Nope, I ran into a discussion topic, given we have a config JSON as follow
which should take priority bucket-1 or bucket-2? |
what do you think? My $.02 in a situation like this would be: ideally throw an error, as it is probably a mistake. Ok, the one in overrides should take precedent. that's what override means, right? |
@@ -123,6 +123,27 @@ describe('S3Adapter tests', () => { | |||
expect(options.bucketPrefix).toEqual('test/'); | |||
}); | |||
|
|||
it('should accept options and overrides as an option in args', () => { | |||
var confObj = { bucketPrefix: 'test/', bucket: 'bucket-1', secretKey: 'secret-1', accessKey: 'key-1' ,s3overrides: { secretAccessKey: 'secret-2', accessKeyId: 'key-2', params: { Bucket: 'bucket-2' }} }; |
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.
nit: add a space after the comma
it should be
, s3over....
not
,s3over...
options[key] = options[key] || process.env[env] || defaultValue; | ||
|
||
//If we used the overrides, |
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.
nit. add space after //
so // If
two suggestions:
|
@acinader Sorry about flooding your feed with commits. I thought this would be a quick fix so I've been editing on the GitHub website. I'll switch over. |
haha well that explains that! |
@@ -133,7 +133,7 @@ describe('S3Adapter tests', () => { | |||
}); | |||
|
|||
it('should accept options and overrides as an Enviromental Variable', () => { | |||
var confObj = { bucketPrefix: 'test/', bucket: 'bucket-1', secretKey: 'secret-1', accessKey: 'key-1' }; | |||
var confObj = { bucketPrefix: 'test/', bucket: 'bucket-1', secretKey: 'secret-1', accessKey: 'key-1'}; |
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.
why'd you take out that trailing space? for consistency, there should be a space between the 1' };
that's how all the other object spacing is done in the file. we just want to be consistent, when possible we put those consistency rules into lint so we don't have to think about it......
Hi |
@aaronschmied unfortunately the unit tests are failing as a direct result of this change. I haven't looked into why that is. |
For everyone who's looking for a quick and dirty fix: RUN npm install && \
npm install --save git+https://github.com/mrmarcsmith/parse-server-s3-adapter && \
npm run build After this I was able to configure my custom s3 endpoint in the parse server's config.json ...
"cloud": "/parse-server/cloud/main.js",
"filesAdapter": {
"module": "parse-server-s3-adapter",
"options": {
"bucket": "bucketname",
"accessKey": "accesskey",
"secretKey": "secretkey",
"region": "region",
"directAccess": true,
"baseUrl": "https://my.custom.s3/bucketname",
"s3overrides": {
"endpoint": "my.custom.s3",
"s3ForcePathStyle": true
}
}
}
} |
it's actually @mrmarcsmith's repo, not mine ;). would be nice to get the unit test fixed and have this merged in.... |
Oh, missed that 😆 |
@aaronschmied no problem! Let me see if I have time today or tomorrow to look into the failing unit test so we can get this merged. |
@mrmarcsmith any news on that? |
- fix typos in unit tests - remove ability to configure s3overrides via environment variables -- can't store objects in env - add a pretty test reporter so i can read output.
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.
I pulled this branch so I could figure out what was going on with the tests to determine what to do with this pr. Now that I have a thorough understanding, I'd like to close this pr un-merged.
-
The idea of passing an object in the environment just does't work. Env vars need to be strings. The unit test that attempts to pass the s3Overrides is failing because the values are not in the env, just the string "[object, object]"
-
the two other tests are failing because this pr doesn't attempt to reconcile the existing difference in names for the AWS Secret. Its secretKey in one place but secretAccessKey in an another (see it in action right here).
While I could attempt to figure out some sensible way to deal with this, I don't want to bother cause a) Its probable that there will be some backward compatibility issue, but more importantly, I'm about to deprecate passing keys and secrets anyway.
@mrmarcsmith if you want help me understand so I can fix, I'm all ears, but given how old this is and that we shouldn't be monkeying with keys and secrets in our code any way since AWS has a super awesome way to deal with it that relieves even having to thinking about how to handle these things securely.
@mrmarcsmith we can reopen, but i'm going to close it pending further discussion with you. |
@acinader thank you for taking the time to look at this PR. That makes a lot of sense about the Env Vars but that is only half of the PR and I would gladly get rid of the Env Var part in favor of being able to pass the override options as a dictionary in the parse server config file. This is a setup (not Env Vars) I am currently using in production because I couldn't find any other way to get it to work before Parse shut down. If I remove the Env Vars part would this PR be considered? |
Since we have removed ENV VAR, I have created a new PR #50 to avoid any confusion. |
Background: when using parse server with a config file there is no way to specify S3Override options.
-This change doesn't affect the current method of passing s3overrides = backwards compatible.
-s3overrides would now be accessible by via parse-server config file like this:
"filesAdapter": {
"module":"parse-server-s3-adapter",
"options":{
"s3overrides": { "endpoint": {"protocol":"https:","host":"$FILEURL","port":443,"hostname":"","pathname":"/","path":"/","href":"https:///"},
"s3BucketEndpoint": false,
ANY OTHER S3OVERRIDES GO HERE... },
"baseUrl": "https://",
"directAccess": true,
"accessKey": "",
"secretKey": "",
"bucket": "",
"region": ""
}
}
-OR in theory (I haven't tested) by Environmental variable like so:
S3_OVERRIDES="{ "endpoint": {"protocol":"https:","host":"$FILEURL","port":443,"hostname":"$FILEURL","pathname":"/","path":"/","href":"https://$FILEURL/"},
"s3BucketEndpoint": false,
ANY OTHER S3OVERRIDES GO HERE... }"