Skip to content

Variables: Expose variable resolver function to variable source resolvers - #9368

Merged
medikoo merged 3 commits into
masterfrom
0420-access-source-resolvers-in-file-resolvers
Apr 27, 2021
Merged

medikoo merged 3 commits into
masterfrom
0420-access-source-resolvers-in-file-resolvers

Conversation

@medikoo

@medikoo medikoo commented Apr 26, 2021 •

Copy link
Copy Markdown
Contributor

Closes: #9112

After all, instead of introducing resolveSource(name, { params, address }), I decided to introduce resolveVariable(variableString) as that feels way more convenient, and I believe more simple to use (it's also a bit more powerful, as supports fallback sources in same manner as when variables are configured into properties).

@codecov

codecov Bot commented Apr 26, 2021 •

Copy link
Copy Markdown

Codecov Report

Merging #9368 (b560b45) into master (c8adc0c) will increase coverage by 0.00%.
The diff coverage is 91.66%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #9368   +/-   ##
=======================================
  Coverage   86.96%   86.97%           
=======================================
  Files         317      317           
  Lines       11855    11865   +10     
=======================================
+ Hits        10310    10319    +9     
- Misses       1545     1546    +1     
Impacted Files Coverage Δ
lib/configuration/variables/resolve.js 99.61% <90.00%> (-0.39%) ⬇️
lib/configuration/variables/sources/file.js 100.00% <100.00%> (ø)

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 c8adc0c...b560b45. Read the comment docs.

@medikoo
medikoo requested a review from pgrzesik April 26, 2021 15:28

@pgrzesik pgrzesik left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks great, I only have two minor comments

Comment thread docs/providers/aws/guide/variables.md Outdated
- `env:SOME_ENV_VAR, null` (end with `, null`, if missing value at the variable source should be resolved with `null`, and not with a thrown error)

Example, of how to obtain a value of AWS region that will be used by Serverless Framework:
Example on how to obtain some Serverless Framework configuratioon values:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

typo: configuratioon

resolveVariable: async (variableString) => {
variableString = `\${${ensureString(variableString, {
Error: ServerlessError,
name: 'variableString',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's add code to ServerlessError via errorCode

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.

Good point, addressed 👍

@medikoo
medikoo force-pushed the 0420-access-source-resolvers-in-file-resolvers branch from 3e07f3b to b560b45 Compare April 27, 2021 10:36
@medikoo
medikoo requested a review from pgrzesik April 27, 2021 10:46

@pgrzesik pgrzesik left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks great, well done 👍

@medikoo
medikoo merged commit 2ff58b1 into master Apr 27, 2021
@medikoo
medikoo deleted the 0420-access-source-resolvers-in-file-resolvers branch April 27, 2021 11:48
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.

Variables: Introduce direct access to source resolvers in JS function resolvers

2 participants