serverless-google-cloudfunctions-awesome
Advanced tools
Comparing version 1.2.4 to 1.3.0
@@ -40,3 +40,3 @@ 'use strict'; | ||
_.forEach(resources.resources, (resource) => { | ||
if (resource.type === 'cloudfunctions.v1beta2.function') { | ||
if (resource.type === 'cloudfunctions.v1.function') { | ||
const serviceFuncName = getFunctionNameInService( | ||
@@ -43,0 +43,0 @@ resource.name, this.serverless.service.service, this.options.stage); |
@@ -120,6 +120,6 @@ 'use strict'; | ||
{ type: 'resource.which.should.be.filterered', name: 'someResource' }, | ||
{ type: 'cloudfunctions.v1beta2.function', name: 'my-service-dev-func1' }, | ||
{ type: 'cloudfunctions.v1beta2.function', name: 'my-service-dev-func2' }, | ||
{ type: 'cloudfunctions.v1beta2.function', name: 'my-service-dev-func3' }, | ||
{ type: 'cloudfunctions.v1beta2.function', name: 'my-service-dev-func4' }, | ||
{ type: 'cloudfunctions.v1.function', name: 'my-service-dev-func1' }, | ||
{ type: 'cloudfunctions.v1.function', name: 'my-service-dev-func2' }, | ||
{ type: 'cloudfunctions.v1.function', name: 'my-service-dev-func3' }, | ||
{ type: 'cloudfunctions.v1.function', name: 'my-service-dev-func4' }, | ||
], | ||
@@ -126,0 +126,0 @@ }; |
{ | ||
"name": "serverless-google-cloudfunctions-awesome", | ||
"version": "1.2.4", | ||
"version": "1.3.0", | ||
"description": "Provider plugin for the Serverless Framework v1.x which adds support for Google Cloud Functions.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -42,2 +42,8 @@ 'use strict'; | ||
|| 256; | ||
funcTemplate.properties.location = _.get(funcObject, 'location') | ||
|| _.get(this, 'serverless.service.provider.region') | ||
|| 'us-central1'; | ||
funcTemplate.properties.runtime = _.get(funcObject, 'runtime') | ||
|| _.get(this, 'serverless.service.provider.runtime') | ||
|| 'nodejs8'; | ||
funcTemplate.properties.timeout = _.get(funcObject, 'timeout') | ||
@@ -132,3 +138,3 @@ || _.get(this, 'serverless.service.provider.timeout') | ||
return { | ||
type: 'cloudfunctions.v1beta2.function', | ||
type: 'cloudfunctions.v1.function', | ||
name: funcObject.name, | ||
@@ -138,2 +144,3 @@ properties: { | ||
availableMemoryMb: 256, | ||
runtime: 'nodejs8', | ||
timeout: '60s', | ||
@@ -140,0 +147,0 @@ entryPoint: funcObject.handler, |
@@ -105,2 +105,3 @@ 'use strict'; | ||
memorySize: 1024, | ||
runtime: 'nodejs8', | ||
events: [ | ||
@@ -113,6 +114,7 @@ { http: 'foo' }, | ||
const compiledResources = [{ | ||
type: 'cloudfunctions.v1beta2.function', | ||
type: 'cloudfunctions.v1.function', | ||
name: 'my-service-dev-func1', | ||
properties: { | ||
location: 'us-central1', | ||
runtime: 'nodejs8', | ||
entryPoint: 'func1', | ||
@@ -149,6 +151,7 @@ function: 'func1', | ||
const compiledResources = [{ | ||
type: 'cloudfunctions.v1beta2.function', | ||
type: 'cloudfunctions.v1.function', | ||
name: 'my-service-dev-func1', | ||
properties: { | ||
location: 'us-central1', | ||
runtime: 'nodejs8', | ||
entryPoint: 'func1', | ||
@@ -185,6 +188,7 @@ function: 'func1', | ||
const compiledResources = [{ | ||
type: 'cloudfunctions.v1beta2.function', | ||
type: 'cloudfunctions.v1.function', | ||
name: 'my-service-dev-func1', | ||
properties: { | ||
location: 'us-central1', | ||
runtime: 'nodejs8', | ||
entryPoint: 'func1', | ||
@@ -221,6 +225,7 @@ function: 'func1', | ||
const compiledResources = [{ | ||
type: 'cloudfunctions.v1beta2.function', | ||
type: 'cloudfunctions.v1.function', | ||
name: 'my-service-dev-func1', | ||
properties: { | ||
location: 'us-central1', | ||
runtime: 'nodejs8', | ||
entryPoint: 'func1', | ||
@@ -259,6 +264,7 @@ function: 'func1', | ||
const compiledResources = [{ | ||
type: 'cloudfunctions.v1beta2.function', | ||
type: 'cloudfunctions.v1.function', | ||
name: 'my-service-dev-func1', | ||
properties: { | ||
location: 'us-central1', | ||
runtime: 'nodejs8', | ||
entryPoint: 'func1', | ||
@@ -299,6 +305,7 @@ function: 'func1', | ||
const compiledResources = [{ | ||
type: 'cloudfunctions.v1beta2.function', | ||
type: 'cloudfunctions.v1.function', | ||
name: 'my-service-dev-func1', | ||
properties: { | ||
location: 'us-central1', | ||
runtime: 'nodejs8', | ||
entryPoint: 'func1', | ||
@@ -343,6 +350,7 @@ function: 'func1', | ||
const compiledResources = [{ | ||
type: 'cloudfunctions.v1beta2.function', | ||
type: 'cloudfunctions.v1.function', | ||
name: 'my-service-dev-func1', | ||
properties: { | ||
location: 'us-central1', | ||
runtime: 'nodejs8', | ||
entryPoint: 'func1', | ||
@@ -381,6 +389,7 @@ function: 'func1', | ||
const compiledResources = [{ | ||
type: 'cloudfunctions.v1beta2.function', | ||
type: 'cloudfunctions.v1.function', | ||
name: 'my-service-dev-func1', | ||
properties: { | ||
location: 'us-central1', | ||
runtime: 'nodejs8', | ||
entryPoint: 'func1', | ||
@@ -447,6 +456,7 @@ function: 'func1', | ||
{ | ||
type: 'cloudfunctions.v1beta2.function', | ||
type: 'cloudfunctions.v1.function', | ||
name: 'my-service-dev-func1', | ||
properties: { | ||
location: 'us-central1', | ||
runtime: 'nodejs8', | ||
entryPoint: 'func1', | ||
@@ -466,6 +476,7 @@ function: 'func1', | ||
{ | ||
type: 'cloudfunctions.v1beta2.function', | ||
type: 'cloudfunctions.v1.function', | ||
name: 'my-service-dev-func2', | ||
properties: { | ||
location: 'us-central1', | ||
runtime: 'nodejs8', | ||
entryPoint: 'func2', | ||
@@ -484,6 +495,7 @@ function: 'func2', | ||
{ | ||
type: 'cloudfunctions.v1beta2.function', | ||
type: 'cloudfunctions.v1.function', | ||
name: 'my-service-dev-func3', | ||
properties: { | ||
location: 'us-central1', | ||
runtime: 'nodejs8', | ||
entryPoint: 'func3', | ||
@@ -513,2 +525,43 @@ function: 'func3', | ||
it('should override runtime in provider with function instead', () => { | ||
googlePackage.options.prependStage = true; | ||
googlePackage.options.prependService = true; | ||
googlePackage.options.runtime = 'nodejs8'; | ||
googlePackage.serverless.service.functions = { | ||
func1: { | ||
handler: 'func1', | ||
runtime: 'nodejs6', | ||
prependStage: false, | ||
prependService: false, | ||
events: [ | ||
{ http: 'foo' }, | ||
], | ||
}, | ||
}; | ||
const compiledResources = [{ | ||
type: 'cloudfunctions.v1.function', | ||
name: 'my-service-dev-func1', | ||
properties: { | ||
location: 'us-central1', | ||
runtime: 'nodejs6', | ||
entryPoint: 'func1', | ||
function: 'func1', | ||
availableMemoryMb: 256, | ||
timeout: '60s', | ||
sourceArchiveUrl: 'gs://sls-my-service-dev-12345678/some-path/artifact.zip', | ||
httpsTrigger: { | ||
url: 'foo', | ||
}, | ||
labels: {}, | ||
}, | ||
}]; | ||
return googlePackage.compileFunctions().then(() => { | ||
expect(consoleLogStub.calledOnce).toEqual(true); | ||
expect(googlePackage.serverless.service.provider.compiledConfigurationTemplate.resources) | ||
.toEqual(compiledResources); | ||
}); | ||
}); | ||
it('should set stage in function name with prependStage', () => { | ||
@@ -526,6 +579,7 @@ googlePackage.serverless.service.functions = { | ||
const compiledResources = [{ | ||
type: 'cloudfunctions.v1beta2.function', | ||
type: 'cloudfunctions.v1.function', | ||
name: 'my-service-dev-func1', | ||
properties: { | ||
location: 'us-central1', | ||
runtime: 'nodejs8', | ||
entryPoint: 'func1', | ||
@@ -563,6 +617,7 @@ function: 'dev-func1', | ||
const compiledResources = [{ | ||
type: 'cloudfunctions.v1beta2.function', | ||
type: 'cloudfunctions.v1.function', | ||
name: 'my-service-dev-func1', | ||
properties: { | ||
location: 'us-central1', | ||
runtime: 'nodejs8', | ||
entryPoint: 'func1', | ||
@@ -602,6 +657,7 @@ function: 'my-service-dev-func1', | ||
const compiledResources = [{ | ||
type: 'cloudfunctions.v1beta2.function', | ||
type: 'cloudfunctions.v1.function', | ||
name: 'my-service-dev-func1', | ||
properties: { | ||
location: 'us-central1', | ||
runtime: 'nodejs8', | ||
entryPoint: 'func1', | ||
@@ -638,6 +694,7 @@ function: 'func1', | ||
const compiledResources = [{ | ||
type: 'cloudfunctions.v1beta2.function', | ||
type: 'cloudfunctions.v1.function', | ||
name: 'my-service-dev-func1', | ||
properties: { | ||
location: 'us-central1', | ||
runtime: 'nodejs8', | ||
entryPoint: 'func1', | ||
@@ -675,6 +732,7 @@ function: 'my-service-func1', | ||
const compiledResources = [{ | ||
type: 'cloudfunctions.v1beta2.function', | ||
type: 'cloudfunctions.v1.function', | ||
name: 'my-service-dev-func1', | ||
properties: { | ||
location: 'us-central1', | ||
runtime: 'nodejs8', | ||
entryPoint: 'func1', | ||
@@ -681,0 +739,0 @@ function: 'my-service-dev-func1', |
@@ -29,4 +29,2 @@ 'use strict'; | ||
logging: google.logging('v2'), | ||
// the following is just a dummy assignment and should be updated | ||
// once the official API is available | ||
cloudfunctions: google.cloudfunctions('v1'), | ||
@@ -33,0 +31,0 @@ }; |
@@ -10,2 +10,3 @@ 'use strict'; | ||
this.options.region = _.get(this, 'options.region', 'us-central1'); | ||
this.options.runtime = _.get(this, 'options.runtime', 'nodejs8'); | ||
@@ -12,0 +13,0 @@ // Normalize booleans, since they're passed as strings |
@@ -23,2 +23,3 @@ 'use strict'; | ||
expect(googleCommand.options.region).toEqual('us-central1'); | ||
expect(googleCommand.options.runtime).toEqual('nodejs8'); | ||
expect(googleCommand.options.prependStage).toEqual(false); | ||
@@ -31,2 +32,3 @@ expect(googleCommand.options.prependService).toEqual(false); | ||
googleCommand.options.region = 'my-region'; | ||
googleCommand.options.runtime = 'nodejs6'; | ||
googleCommand.serverless.service = { | ||
@@ -42,2 +44,3 @@ provider: { | ||
expect(googleCommand.options.region).toEqual('my-region'); | ||
expect(googleCommand.options.runtime).toEqual('nodejs6'); | ||
expect(googleCommand.options.prependStage).toEqual(true); | ||
@@ -44,0 +47,0 @@ expect(googleCommand.options.prependService).toEqual(true); |
257342
4511