8483 Commits

Author SHA1 Message Date
Erik Erikson
bf5a8c9fd4 Fix 4744 and associated
The framework's Service class modifies a user's service, mutating a given `service: { name: 'string' }` to `service: 'string'` but doesn't account for this in the variables system.  This is the basis for #4744.

While working this area, I discovered that the Service class also does this to the provider, accepting `provider: 'aws'` and replacing it with `provider: { name: 'aws' }`, causing the natural `${self:provider}` to fail.

Catching either 'self:service.name' or 'self:provider' and replacing them with the mutated reference solves this user confusion.
2018-02-22 17:17:55 -08:00
Erik Erikson
dc3a4aa6af Fix print, clean pre-population, fix cyclic bug
Fix `print`
The print command is highly linked to the `Variables` and `Service` codebases, keep those in sync and leave reminders about the link.  Made these explicit and separately implemented to avoid complexity.
Additionally, the print command re-populates an object with the *very similar* content as the previously pre-populated service (just not augmented as just mentioned).  This can lead to cross contamination between the two.  As such, all caches must be cleared per unique invocation of service/object/property population.
Add tests for some expected but previously unverified behaviors.

Clean pre-population
The previous implementation worked okay but was unnecessary and would have been a maintenance problem.  Instead, just knock out the population of variables depending on those config dependent services and use the standard means of resolution.

Fix cyclic bug (resulting from running print against a self-referencing serverless.yml)
The caching of values could lead to a cyclic object remaining in the caches for variable population.  This causes crashes and pain.  Solved by the cache cleaning logic.
2018-02-22 16:30:04 -08:00
icj217
a4de7288f3
Added name property to CloudFormation template
Now when a user specifies a name property under the cloudwatchEvent, it will be carried over to the CF template.
2018-02-22 13:21:50 -05:00
Takahiro Horike
897961d475
Merge pull request #4757 from alexindeed/master
Added IAM roles support
2018-02-22 14:37:43 +09:00
Alex
90f89ec2fd fixed attribute 2018-02-21 18:02:04 -08:00
Jakob Fix
5618c5a453
Fix typo in sub-heading
compatability -> compatibility (nitpicking, I know)
2018-02-21 23:01:04 +01:00
Kamesh Sampath
e6692aa1fd Resolving #4491 , adding support for java maven templates for OpenWhisk
Signed-off-by: Kamesh Sampath <kamesh.sampath@hotmail.com>
2018-02-22 00:42:52 +05:30
Alex
aa24154ca9 updated menu 2018-02-21 11:10:43 -08:00
Alex
ecf37ebaab updated links 2018-02-21 10:49:29 -08:00
Alex
0940fd4595 updated templates 2018-02-21 10:39:50 -08:00
Devin Fee
d1d1b05cea Fixed python module parsing (#4755)
* Fixed python module parsing

Ref: https://github.com/serverless/serverless/issues/4663#issuecomment-366931491

* Update index.js

* Update index.js
2018-02-21 18:59:42 +01:00
Takahiro Horike
ac5b6df517
Merge pull request #4756 from atsuky/patch-1
Fixed a typo
2018-02-21 18:28:20 +09:00
Andreu Gallofré
e572563441
Fixed a typo
It's supposed to say python code, but it says nodejs two times
2018-02-21 10:06:53 +01:00
Erik Erikson
8c7db120ae Add cases for all dependent services, and a variety of deep variable (DV) cases
Solve for these cases.  The bug was that DVs can render to DVs when a value is being obtained from them (i.e. they are being de-referenced in getValueFromDeep).  This is particularly problematic in the case that the original DV being rendered has a deep reference into the rendered DV.  In that case the DV returned by rendering must be replaced by yet another DV.

While accomplishing the above, various bits of cleanup were implemented and I added some commentary around getDeeperValue for future engineers.

This case is particularly relevant if you have:

`serverless.yml`:
```
service: serverless-hello-world

provider:
  name: aws
  runtime: nodejs6.10
  stage: dev
  environment:
    SECRET: ${self:custom.secrets.SECRET}

functions:
  helloWorld:
    handler: handler.helloWorld
    events:
      - http:
          path: hello-world
          method: get
          cors: true

custom:
  stage: ${opt:stage, self:provider.stage}
  secrets: ${file(secrets.${self:custom.stage}.yml)}
```
AND
`secrets.dev.yml`:
```
SECRETS: secrets
```

Populating this service should result in the following sequence of rendering phases:

#########################
# PHASE 1
#
# ${self:custom.secrets.SECRET}
#   <- ${deep:0.SECRET}
#   deep[0] = ${file(secrets.${self:custom.stage}.yml)}
#
# ${opt:stage, self:provider.stage}
#   <- 'dev'
#
# ${file(secrets.${self:custom.stage}.yml)}
#   <- ${file(secrets.${deep:1}.yml)}
#   deep[1] = ${opt:stage, self:provider.stage}
#
# RESULT
#
# service: serverless-hello-world
#
# provider:
#   name: aws
#   runtime: nodejs6.10
#   stage: dev
#   environment:
#     SECRET: ${deep:0.SECRET}
#
# functions:
#   helloWorld:
#     handler: handler.helloWorld
#     events:
#       - http:
#           path: hello-world
#           method: get
#           cors: true
#
# custom:
#   stage: dev
#   secrets: ${file(secrets.${deep:1}.yml)}
#########################

#########################
# PHASE 2
#
# ${deep:0.SECRET}
#   <- this.populateValue('${file(secrets.${self:custom.stage}.yml)}') => '${file(secrets.${deep:1}.yml)}' => '${deep:2}' => '${deep:2.SECRET}'
#   deep[2] = ${file(secrets.${deep:1}.yml)}
#
# ${file(secrets.${deep:1}.yml)}
#   <- this.populateValue('${file(secrets.${deep:1}.yml)}') => '${file(secrets.dev.yml)}' => '${deep:3}'
#   deep[3] = ${file(secrets.dev.yml)}
#
# RESULT
#
# service: serverless-hello-world
#
# provider:
#   name: aws
#   runtime: nodejs6.10
#   stage: dev
#   environment:
#     SECRET: ${deep:2.SECRET}
#
# functions:
#   helloWorld:
#     handler: handler.helloWorld
#     events:
#       - http:
#           path: hello-world
#           method: get
#           cors: true
#
# custom:
#   stage: dev
#   secrets: ${deep:3}
#########################

#########################
# PHASE 3
#
# ${deep:2.SECRET}
#   <- this.populateValue('${file(secrets.${deep:1}.yml)}') => '${file(secrets.dev.yml)}' => '${deep:3}' => '${deep:3.SECRET}'
#   deep[3] is already set to ${file(secrets.dev.yml)}
#
# ${deep:3}
#   <- this.populateValue('${file(secrets.dev.yml)}') => { SECRET: 'secret' }
#
# RESULT
#
# service: serverless-hello-world
#
# provider:
#   name: aws
#   runtime: nodejs6.10
#   stage: dev
#   environment:
#     SECRET: ${deep:3.SECRET}
#
# functions:
#   helloWorld:
#     handler: handler.helloWorld
#     events:
#       - http:
#           path: hello-world
#           method: get
#           cors: true
#
# custom:
#   stage: dev
#   secrets:
#     SECRET: secret
#########################

#########################
# PHASE 4
#
# ${deep:3}
#   <- this.populateValue('${file(secrets.dev.yml)}') => this.getDeeperValue(['SECRET'], { SECRET: 'secret' }) => 'secret'
#
# RESULT
#
# service: serverless-hello-world
#
# provider:
#   name: aws
#   runtime: nodejs6.10
#   stage: dev
#   environment:
#     SECRET: secret
#
# functions:
#   helloWorld:
#     handler: handler.helloWorld
#     events:
#       - http:
#           path: hello-world
#           method: get
#           cors: true
#
# custom:
#   stage: dev
#   secrets:
#     SECRET: secret
#########################
2018-02-20 20:57:24 -08:00
Alex
3b278f4d6b added IAM roles docs 2018-02-20 16:16:55 -08:00
Erik Erikson
a35bcc01cd Deep values can be overwrites too! Fix issue reported by @laardee (thank you!)
Simple oversight that deep variables can reference overwrites too.  This fix acknowledges this oversight by using the standard logic for using overwrite instead of getValueFromSource in this case.
2018-02-20 12:21:26 -08:00
Frank Schmid
39caddc404
Merge pull request #4713 from erikerikson/fix-4687-cyclic-variable-dependencies
Eliminate/Report Hung Promises (#4687), Prepopulate Stage and Region (#4311), Handle Quoted Strings (#4734)
2018-02-20 13:56:27 +01:00
Takahiro Horike
9849e926d1
Merge pull request #4741 from chrisoverzero/feature/angle-brackets
Wraps Poorly Parsing URL in Angle Brackets
2018-02-19 08:36:10 +01:00
Simon Males
2e3144f593 Include node_modules when compiling TypeScript 2018-02-17 21:18:14 +01:00
Erik Erikson
ffc7686465 fix pending promise test bugs 2018-02-16 18:46:28 -08:00
Erik Erikson
91f50f6918 add 'use strict' for node 4.x and 5.x 2018-02-16 17:26:40 -08:00
Erik Erikson
4400ffc9e4 fix #4311 & #4734, separate PromiseTracker, minutiae
#4311
  see prepopulateService - attempts to pre-populate the region and stage settings necessary for making a request to AWS, rejecting and dependencies thereon it runs into during that process
  see the `deep` variable work.  this was a knock-on effect of providing pre-population.  it actually represents an obscure class of bugs where the recursive population previously in getDeepValue caused the caller not to be in charge of population choices (thus fixing for pre-population) but also caused potential deadlocks resulting from getDeepValue creating circular dependencies.

#4734
  see splitByComma - a regex to do the splitting but ignore quoted commas was getting very deep and involved.  Instead, identify quoted string boundaries, then identify commas (including white space around them) and take those commas not contained by quotes as the locations for splitting the given string.  Trim the string as well (removing leading and trailing white space).
  add sophistication to the overwrite syntax, allowing for whitespace and repetitions (for robustness)
  add sophistication to the string ref syntax, allowing for use in identifying multiple quoted strings in a variable (i.e. for overwrites)

#NotCreated
  fix a bug I created earlier in the branch that caused reporting to be less informative (see renderMatches)

separate PromiseTracker
  move this class into its own file for the purpose of increasing testability and offering reuse

minutiae
  filter the properties given to populateVariables so as to avoid attempting resolution on non-variables.  Efficiency and noise reduction change.  Also cleans up the code (e.g. see populateObject and its use)
  cleaning of overwrite as a side effect
  offer variable cleaning as a idiom
  reorder the Variables.js `require`s to be in alphabetical order
2018-02-16 17:13:03 -08:00
Sander van de Graaf
63c57e7122
Added reference to serverless parameter 2018-02-15 16:00:21 +01:00
Sander van de Graaf
8abcee66a4
Pass the serverless variable as parameter to the receiving function 2018-02-15 15:59:45 +01:00
Christopher Osborn
edd863be01
Wraps Poorly Parsing URL in Angle Brackets
As suggested by <https://tools.ietf.org/html/rfc3986?#appendix-C>.

[#4674]
2018-02-12 16:54:00 -05:00
Takahiro Horike
63517f6a30
Merge pull request #4736 from alexindeed/master
Spotinst - Updated the documentation, menu order
2018-02-11 11:52:09 +09:00
Takahiro Horike
97b6328438
Merge pull request #4733 from msfidelis/serverless-architecture-boilerplate
Add serverless-architecture-boilerplate
2018-02-09 09:17:03 +09:00
Alex
4218e77bca updated description 2018-02-08 15:29:34 -08:00
Alex
d4598f758f formatting 2018-02-08 15:25:05 -08:00
Alex
c4c0dc8e02 resolved merge conflict 2018-02-08 15:18:15 -08:00
Alex
4cfa8afaf1 formatting, page order corrected 2018-02-08 15:05:04 -08:00
Alex
c1bd397b4c refactored json to yml 2018-02-08 14:41:37 -08:00
Alex
8083fd5ef9 removed json from yml 2018-02-08 13:24:20 -08:00
Matheus Fidelis
396c800fff
Add serverless-architecture-boilerplate 2018-02-08 18:09:02 -02:00
Simon Males
bd6b48ab85 Enable TypeScript file source map support in TypeScript template 2018-02-08 15:26:26 +01:00
Mike Pugh
5477eb2bb4 Update tests involving getAccountInfoStub 2018-02-08 09:19:57 -05:00
Takahiro Horike
85ae7a72b0
Merge pull request #4731 from tomdyson/patch-1
Google docs intro typo
2018-02-08 18:42:26 +09:00
Takahiro Horike
bc17f3ab6f
Merge pull request #4730 from jeffnoehren/master
Spotinst - reorganizing guide structure for readability
2018-02-08 17:53:57 +09:00
Tom Dyson
037a9de63e
Google docs intro typo 2018-02-08 08:51:06 +00:00
Mike Pugh
1f9e32d4c8 Reverting test file back to old version to avoid linting issues 2018-02-07 20:03:14 -05:00
Mike Pugh
7b6a8ff262 Lodash and test updates 2018-02-07 19:50:24 -05:00
jeffnoehren
9b53816716 Spotinst - reformatting docs to be more readable 2018-02-07 16:36:20 -08:00
Jeffrey Noehren
404e780c8c
Merge pull request #11 from serverless/master
updating branch
2018-02-07 16:07:59 -08:00
Takahiro Horike
a876d6734d
Merge pull request #4727 from alexindeed/master
Spotinst: Added support for CORS for Functions
2018-02-07 10:49:03 +09:00
Alex
cfe4f4b12b Merge branch 'master' of https://github.com/alexindeed/serverless 2018-02-06 17:13:19 -08:00
Alex
e894983ad0 squashed commit 2018-02-06 17:13:08 -08:00
Erik Erikson
3606589ff2 Do not double-reject errors
Calling .then here creates a new promise.  One that is not returned and generating a rejection within that promise can lead to unhandledRejection events being inappropriately raised.
As such, don't declare unneeded variables.
2018-02-06 16:35:16 -08:00
Alex Gaesser
42b2132072
Update cors.md 2018-02-05 19:20:58 -08:00
Alex
77582bd341 updated templates, added CORS support and docs 2018-02-05 17:53:39 -08:00
Alex Gaesser
8dde4c7e22
Merge pull request #1 from serverless/master
update fork
2018-02-05 15:10:09 -08:00