Skip to content
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

Enable execution of SAM from existing template #314

Merged
merged 2 commits into from Oct 19, 2018

Conversation

kiiadi
Copy link
Contributor

@kiiadi kiiadi commented Oct 19, 2018

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Description

Current SAM workflows generate a dummy template on the fly, this feature enables the use of an existing template from within the project.

One can also create run configurations from the YAML template directly.

Motivation and Context

Best practice is to define functions as part of an infrastructure template - this enables debugging locally from such a template.

Related Issue(s)

#261

Testing

New tests added.

Screenshots (if appropriate)

2018-10-19_11-40-28

Checklist

  • I have read the README document
  • I have read the CONTRIBUTING document
  • Local run of gradlew check succeeds
  • My code follows the code style of this project
  • I have added tests to cover my changes
  • All new and existing tests passed
  • A short description of the change has been added to the CHANGELOG

License

I confirm that my contribution is made under the terms of the Apache 2.0 license.

@codecov-io
Copy link

codecov-io commented Oct 19, 2018

Codecov Report

Merging #314 into master will decrease coverage by 6.14%.
The diff coverage is 30.04%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master     #314      +/-   ##
============================================
- Coverage     48.77%   42.62%   -6.15%     
- Complexity      254      277      +23     
============================================
  Files            92       94       +2     
  Lines          2282     2442     +160     
  Branches        295      332      +37     
============================================
- Hits           1113     1041      -72     
- Misses         1072     1284     +212     
- Partials         97      117      +20
Flag Coverage Δ Complexity Δ
#integtest ? ?
#unittest 42.62% <30.04%> (-0.76%) 277 <32> (+38)
Impacted Files Coverage Δ Complexity Δ
...s/services/lambda/execution/sam/SamRunningState.kt 8.82% <0%> (-91.18%) 2 <0> (-5)
...s/services/lambda/execution/sam/SamInvokeRunner.kt 5.76% <0%> (-71.16%) 3 <0> (-5)
...jetbrains/services/lambda/LambdaHandlerResolver.kt 50% <0%> (-50%) 0 <0> (ø)
...ambda/execution/sam/SamRunSettingsEditorPanel.java 0% <0%> (ø) 0 <0> (ø) ⬇️
...aws/toolkits/ktlint/rules/CustomRuleSetProvider.kt 0% <0%> (ø) 0 <0> (ø) ⬇️
...ns/services/lambda/execution/LambdaInputPanel.java 0% <0%> (ø) 0 <0> (ø) ⬇️
...a/execution/remote/LambdaRemoteRunConfiguration.kt 28.43% <100%> (ø) 6 <1> (ø) ⬇️
.../services/lambda/java/JavaLambdaHandlerResolver.kt 91.04% <100%> (+0.13%) 61 <1> (+1) ⬆️
...rvices/lambda/execution/sam/SamRunConfiguration.kt 40.38% <36.36%> (-5.65%) 10 <3> (+2)
...ins/services/lambda/execution/sam/TemplateUtils.kt 40% <40%> (ø) 14 <14> (?)
... and 13 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 79402ef...5c2322d. Read the comment docs.

val element = context.psiLocation ?: return false
val parent = element.parent
Copy link
Contributor

Choose a reason for hiding this comment

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

Why does setup require the parent, yet isConfigfromContext doesnt?

Are the contexts not equal?

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 catch - added a test and fixed the logic.

val keyValue = element as? YAMLKeyValue ?: return null
val value = keyValue.value as? YAMLMapping ?: return null
val type = value.getKeyValueByKey("Type")?.valueText ?: return null
if (type != FUNCTION_TYPE) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we support AWS::Lambda::Function too, since that can also be used inside a SAM template?

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 - #318

}

private void updateComponents() {

Copy link
Contributor

Choose a reason for hiding this comment

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

extra line

Suggested change

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed


private void updateFunctionModel(List<SamFunction> functions) {
functionModels.removeAllElements();
if (functions.size() == 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

functions.setEnabled(!functions.isEmpty())

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@@ -0,0 +1,15 @@
AWSTemplateFormatVersion: '2010-09-09'
Copy link
Contributor

Choose a reason for hiding this comment

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

What test uses this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nothing it's just the dummy file that i often use as a manual test project

@kiiadi kiiadi force-pushed the kiiadi/adding-template-support branch from fb2c905 to bbc1bf7 Compare October 19, 2018 22:34
@kiiadi kiiadi merged commit 9d98f62 into master Oct 19, 2018
@abrooksv abrooksv deleted the kiiadi/adding-template-support branch October 19, 2018 23:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants