Skip to content

Conversation

@medikoo
Copy link
Contributor

@medikoo medikoo commented Mar 30, 2021

Closes: #8364

Accompanied by https://github.com/serverless/enterprise-plugin/pull/558 (ideally if it's merged right after this one, and released before we release new Framework version)

Configures all remaining variables sources in new variable resolver

@codecov
Copy link

codecov bot commented Mar 30, 2021

Codecov Report

Merging #9200 (9ee706c) into master (b31892a) will decrease coverage by 0.28%.
The diff coverage is 68.68%.

❗ Current head 9ee706c differs from pull request most recent head e88c49c. Consider uploading reports for the commit e88c49c to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master    #9200      +/-   ##
==========================================
- Coverage   87.24%   86.96%   -0.29%     
==========================================
  Files         310      315       +5     
  Lines       11485    11651     +166     
==========================================
+ Hits        10020    10132     +112     
- Misses       1465     1519      +54     
Impacted Files Coverage Δ
lib/configSchema.js 100.00% <ø> (ø)
...n/variables/eventually-report-resolution-errors.js 100.00% <ø> (ø)
lib/configuration/variables/sources/file.js 100.00% <ø> (ø)
scripts/serverless.js 50.67% <31.76%> (-13.40%) ⬇️
...on/variables/sources/instance-dependent/get-ssm.js 92.50% <92.50%> (ø)
...ion/variables/sources/instance-dependent/get-cf.js 95.65% <95.65%> (ø)
lib/classes/PluginManager.js 97.49% <100.00%> (+<0.01%) ⬆️
...ation/variables/resolve-unresolved-source-types.js 100.00% <100.00%> (ø)
...ion/variables/sources/instance-dependent/get-s3.js 100.00% <100.00%> (ø)
...on/variables/sources/instance-dependent/get-sls.js 100.00% <100.00%> (ø)
... and 5 more

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 b31892a...e88c49c. Read the comment docs.

@medikoo medikoo force-pushed the 0326-remaining-variable-sources branch from 9b965ed to dd7db91 Compare March 30, 2021 07:38
@medikoo medikoo requested a review from pgrzesik March 30, 2021 07:44
@medikoo medikoo force-pushed the 0326-remaining-variable-sources branch from dd7db91 to 70a2f9d Compare March 30, 2021 07:47
Copy link
Contributor

@pgrzesik pgrzesik left a comment

Choose a reason for hiding this comment

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

Looks great overall 👏 I only have a few minor comments/questions, please let me know what do you think

The above plugin will add support for variables like `${echo:foobar}` and resolve to the key. EG:
`${echo:foobar}` will resolve to `'foobar'`.
this.configurationVariablesSources = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Just to be extra sure - the old way of defining variables won't work and plugins will have to migrate to new approach, correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, but that'll happen with a new major (no support is dropped with this PR)

it's dictated simply by fact that old variables resolver will be removed with next major, and same way old extensions will stop working.

However I don't think this feature is that used. It was created to aid dashboard plugin, and I'm not sure if any other plugins really benefited from that (and if they did migration will be really easy, you may check, how it looks in enterprise plugin PR)

Copy link
Contributor

Choose a reason for hiding this comment

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

I just saw that in the related plugin PR - thanks for clarification - that's what I thought but wanted to make sure I'm not missing something here 👍

// Note: they're passed if they're configured into variable

// `options` is CLI options
// `resolveConfigurationProperty` allows to access other confuguration properties,
Copy link
Contributor

Choose a reason for hiding this comment

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

small typo: confuguration -> configuration

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, fixed

Error: ServerlessError,
errorMessage: 'Non-string address argument in variable "cf" source: %v',
});
const separatorIndex = address.indexOf('.');
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think of splitting the address on . character and then verifying if it has length of 2 and destructuring the resulting array to stack name and logical id? In the current situation someone can provide by mistake an address like stackName.output.something which will be invalid but won't be caught here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thnk it's fine to assume then that output.something is target output name. Is such naming not supported by AWS?

Copy link
Contributor

Choose a reason for hiding this comment

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

The output names have to be alphanumeric only and don't allow . in name, but I guess it's an edge case here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I think we may leave this (at least at this point) to AWS validation. User should anyway be presented with meaningful message.

@medikoo medikoo force-pushed the 0326-remaining-variable-sources branch from 70a2f9d to e88c49c Compare March 30, 2021 08:07
@medikoo medikoo requested a review from pgrzesik March 30, 2021 08:07
Copy link
Contributor

@pgrzesik pgrzesik 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 🙌

@medikoo medikoo merged commit 1d77f46 into master Mar 30, 2021
@medikoo medikoo deleted the 0326-remaining-variable-sources branch March 30, 2021 08:22
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.

Seclude CLI params and service config resolution from the core

3 participants