Add support in Spotinst Function.

added 2 new templates - spotinst-nodejs, spotinst-python
This commit is contained in:
guyklainer 2017-08-20 09:49:18 +03:00
parent ae926c2ab6
commit d4ed0f70ab
8 changed files with 141 additions and 0 deletions

View File

@ -24,6 +24,8 @@ const validTemplates = [
'openwhisk-nodejs',
'openwhisk-python',
'openwhisk-swift',
'spotinst-nodejs',
'spotinst-python',
'plugin',
// this template is used to streamline the onboarding process

View File

@ -0,0 +1,6 @@
# package directories
node_modules
jspm_packages
# Serverless directories
.serverless

View File

@ -0,0 +1,25 @@
/*
*
* Implement your function here.
* The function will get the request as a parameter with query/body properties:
* var queryparams = req.query;
* var body = req.body;
*
* The function should return a Promise that resolves with the following structure:
* resolve({
* statusCode: 200,
* body: '{"hello":"from NodeJS4.8 function"}',
* headers: {"Content-Type": "application/json"}
* })
*
*/
exports.main = function main (req, res) {
// The function should return a Promise.
return new Promise(function(resolve, reject){
return resolve({
statusCode: 200,
body: `hello ${req.query.name || "world"}!`
});
});
};

View File

@ -0,0 +1,10 @@
{
"name": "spotionst-nodejs",
"version": "1.0.0",
"description": "Spotinst Functions NodeJS sample for serverless framework service.",
"main": "handler.js",
"keywords": [
"serverless",
"spotinst"
]
}

View File

@ -0,0 +1,39 @@
# Welcome to Serverless!
#
# This file is the main config file for your service.
# It's very minimal at this point and uses default values.
# You can always add more config options for more control.
# We've included some commented out config examples here.
# Just uncomment any of them to get that config option.
#
# For full config options, check the docs:
# docs.serverless.com
#
# Happy Coding!
service: spotinst-nodejs # NOTE: update this with your service name
provider:
name: spotinst
runtime: nodejs4.8
#environment: <env-XXXX> # NOTE: Remember to add the environment ID
#account: <act-XXXX> # NOTE: Remember to add the account ID
# you can add packaging information here
#package:
# include:
# - include-me.js
# - include-me-dir/**
# exclude:
# - exclude-me.js
# - exclude-me-dir/**
functions:
hello:
handler: main
# extend the framework using plugins listed here:
# https://github.com/serverless/plugins
plugins:
- serverless-spotinst-functions

View File

@ -0,0 +1,6 @@
# package directories
node_modules
jspm_packages
# Serverless directories
.serverless

View File

@ -0,0 +1,14 @@
# Implement your function here.
# The function will get the request as parameter.
# The function should return an object
def main(args):
queryparams = args.get("query", {})
body = args.get("body", {})
return {
'statusCode': 200,
'body': '{"hello":"from Python2.7 function"}',
'headers': {"Content-Type": "application/json"}
}

View File

@ -0,0 +1,39 @@
# Welcome to Serverless!
#
# This file is the main config file for your service.
# It's very minimal at this point and uses default values.
# You can always add more config options for more control.
# We've included some commented out config examples here.
# Just uncomment any of them to get that config option.
#
# For full config options, check the docs:
# docs.serverless.com
#
# Happy Coding!
service: spotinst-nodejs # NOTE: update this with your service name
provider:
name: spotinst
runtime: nodejs4.8
#environment: <env-XXXX> # NOTE: Remember to add the environment ID
#account: <act-XXXX> # NOTE: Remember to add the account ID
# you can add packaging information here
#package:
# include:
# - include-me.js
# - include-me-dir/**
# exclude:
# - exclude-me.js
# - exclude-me-dir/**
functions:
hello:
handler: main
# extend the framework using plugins listed here:
# https://github.com/serverless/plugins
plugins:
- serverless-spotinst-functions