Skip to content

feat(verdaccio-aws-s3-storage): supporting environment variables#315

Merged
juanpicado merged 4 commits intoverdaccio:masterfrom
grabyo:supporting-environment-variables
Jan 25, 2020
Merged

feat(verdaccio-aws-s3-storage): supporting environment variables#315
juanpicado merged 4 commits intoverdaccio:masterfrom
grabyo:supporting-environment-variables

Conversation

@nszilard
Copy link
Copy Markdown
Contributor

Type: Feature
Scope: aws-s3-storage

Description:

Resolves #314
Add support for environment variables when reading the config values.

@codecov
Copy link
Copy Markdown

codecov bot commented Jan 22, 2020

Codecov Report

Merging #315 into master will decrease coverage by 0.2%.
The diff coverage is 28.57%.

Impacted file tree graph

@@            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
Flag Coverage Δ
#core 88.18% <ø> (ø) ⬆️
#plugins 63.12% <28.57%> (-0.19%) ⬇️
Impacted Files Coverage Δ
plugins/aws-s3-storage/src/index.ts 0% <0%> (ø) ⬆️
plugins/aws-s3-storage/src/setConfigValue.ts 100% <100%> (ø)

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 6639a71...586490b. Read the comment docs.

throw new Error('s3 storage requires a bucket');
}
const configKeyPrefix = this.config.keyPrefix;
this.config.bucket = process.env[this.config.bucket] || this.config.bucket;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you provide some examples or how the users might use this ? to have a better overview of your solution.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Example 1:

store:
  aws-s3-storage:
    bucket: S3_BUCKET
    keyPrefix: someConstantPrefix
    region: S3_BUCKET_REGION

Given the following environment variables are set on the host running Verdaccio:

  • S3_BUCKET=myBucket
  • S3_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-1

Given 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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Great ! I like it. Could you rebase from master and add this examples to the README? I think will have more visibility.

juanpicado
juanpicado previously approved these changes Jan 23, 2020
Copy link
Copy Markdown
Member

@juanpicado juanpicado left a comment

Choose a reason for hiding this comment

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

Great !! 🥳

@juanpicado juanpicado requested review from a team January 23, 2020 14:00
@weyert
Copy link
Copy Markdown
Contributor

weyert commented Jan 23, 2020

Love this!

Copy link
Copy Markdown
Member

@juanpicado juanpicado left a comment

Choose a reason for hiding this comment

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

Thanks so much for this kickass feature 👏 , I tested it and works perfectly.

@juanpicado juanpicado merged commit 0c532f0 into verdaccio:master Jan 25, 2020
@nszilard nszilard deleted the supporting-environment-variables branch January 25, 2020 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(aws-s3-storage) Support for environment variables

3 participants