feat(verdaccio-aws-s3-storage): supporting environment variables#315
feat(verdaccio-aws-s3-storage): supporting environment variables#315juanpicado merged 4 commits intoverdaccio:masterfrom grabyo:supporting-environment-variables
Conversation
Codecov Report
@@ Coverage Diff @@
## master #315 +/- ##
==========================================
- Coverage 70.62% 70.42% -0.21%
==========================================
Files 27 28 +1
Lines 1413 1420 +7
Branches 206 207 +1
==========================================
+ Hits 998 1000 +2
- Misses 412 417 +5
Partials 3 3
Continue to review full report at Codecov.
|
plugins/aws-s3-storage/src/index.ts
Outdated
| throw new Error('s3 storage requires a bucket'); | ||
| } | ||
| const configKeyPrefix = this.config.keyPrefix; | ||
| this.config.bucket = process.env[this.config.bucket] || this.config.bucket; |
There was a problem hiding this comment.
Could you provide some examples or how the users might use this ? to have a better overview of your solution.
There was a problem hiding this comment.
Example 1:
store:
aws-s3-storage:
bucket: S3_BUCKET
keyPrefix: someConstantPrefix
region: S3_BUCKET_REGIONGiven the following environment variables are set on the host running Verdaccio:
S3_BUCKET=myBucketS3_BUCKET_REGION=some-aws-region
This would result in the plugin initialization with the following values:
{
"bucket": "myBucket",
"keyPrefix": "someConstantPrefix",
"region": "some-aws-region"
}Example 2:
store:
aws-s3-storage:
bucket: bucketName
keyPrefix: someConstantPrefix
region: eu-west-1Given there are NO environment variables are set with names bucketName, someConstantPrefix and eu-west-1:
This would result in the plugin initialization with the following values:
{
"bucket": "bucketName",
"keyPrefix": "someConstantPrefix",
"region": "eu-west-1"
}Example 3
AWS Access keys would have similar behaviour with the addition of:
if no environment variables are set and there are also no values provided in the config.yaml file, then it falls back using the instance/container's IAM role.
There was a problem hiding this comment.
Great ! I like it. Could you rebase from master and add this examples to the README? I think will have more visibility.
|
Love this! |
juanpicado
left a comment
There was a problem hiding this comment.
Thanks so much for this kickass feature 👏 , I tested it and works perfectly.
Type: Feature
Scope:
aws-s3-storageDescription:
Resolves #314
Add support for environment variables when reading the config values.