mirror of
https://github.com/serverless/serverless.git
synced 2025-12-08 19:46:03 +00:00
Add support in Spotinst Function.
added 2 new templates - spotinst-nodejs, spotinst-python
This commit is contained in:
parent
ae926c2ab6
commit
d4ed0f70ab
@ -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
|
||||
|
||||
6
lib/plugins/create/templates/spotinst-nodejs/gitignore
Normal file
6
lib/plugins/create/templates/spotinst-nodejs/gitignore
Normal file
@ -0,0 +1,6 @@
|
||||
# package directories
|
||||
node_modules
|
||||
jspm_packages
|
||||
|
||||
# Serverless directories
|
||||
.serverless
|
||||
25
lib/plugins/create/templates/spotinst-nodejs/handler.js
Normal file
25
lib/plugins/create/templates/spotinst-nodejs/handler.js
Normal 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"}!`
|
||||
});
|
||||
});
|
||||
};
|
||||
10
lib/plugins/create/templates/spotinst-nodejs/package.json
Normal file
10
lib/plugins/create/templates/spotinst-nodejs/package.json
Normal 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"
|
||||
]
|
||||
}
|
||||
39
lib/plugins/create/templates/spotinst-nodejs/serverless.yml
Normal file
39
lib/plugins/create/templates/spotinst-nodejs/serverless.yml
Normal 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
|
||||
6
lib/plugins/create/templates/spotinst-python/gitignore
Normal file
6
lib/plugins/create/templates/spotinst-python/gitignore
Normal file
@ -0,0 +1,6 @@
|
||||
# package directories
|
||||
node_modules
|
||||
jspm_packages
|
||||
|
||||
# Serverless directories
|
||||
.serverless
|
||||
14
lib/plugins/create/templates/spotinst-python/handler.py
Normal file
14
lib/plugins/create/templates/spotinst-python/handler.py
Normal 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"}
|
||||
}
|
||||
39
lib/plugins/create/templates/spotinst-python/serverless.yml
Normal file
39
lib/plugins/create/templates/spotinst-python/serverless.yml
Normal 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
|
||||
Loading…
x
Reference in New Issue
Block a user