Skip to content

Commit df3aac0

Browse files
fix: add region and runtime to deploy template, fixes #113 and #112
1 parent bb971b7 commit df3aac0

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

package/lib/compileFunctions.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,26 @@ module.exports = {
2424
validateHandlerProperty(funcObject, functionName);
2525
validateEventsProperty(funcObject, functionName);
2626

27+
console.log('----------------------------------------------------------')
28+
console.log(this.options)
29+
console.log('----------------------------------------------------------')
30+
2731
const funcTemplate = getFunctionTemplate(
2832
funcObject,
2933
this.options.region,
3034
`gs://${
31-
this.serverless.service.provider.deploymentBucketName
35+
this.serverless.service.provider.deploymentBucketName
3236
}/${this.serverless.service.package.artifactFilePath}`);
3337

3438
funcTemplate.properties.availableMemoryMb = _.get(funcObject, 'memorySize')
3539
|| _.get(this, 'serverless.service.provider.memorySize')
3640
|| 256;
41+
funcTemplate.properties.location = _.get(funcObject, 'location')
42+
|| _.get(this, 'serverless.service.provider.region')
43+
|| 'us-central1';
44+
funcTemplate.properties.runtime = _.get(funcObject, 'runtime')
45+
|| _.get(this, 'serverless.service.provider.runtime')
46+
|| 'nodejs8';
3747
funcTemplate.properties.timeout = _.get(funcObject, 'timeout')
3848
|| _.get(this, 'serverless.service.provider.timeout')
3949
|| '60s';

package/lib/compileFunctions.test.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ describe('CompileFunctions', () => {
102102
func1: {
103103
handler: 'func1',
104104
memorySize: 1024,
105+
runtime: 'nodejs8',
105106
events: [
106107
{ http: 'foo' },
107108
],
@@ -113,6 +114,7 @@ describe('CompileFunctions', () => {
113114
name: 'my-service-dev-func1',
114115
properties: {
115116
location: 'us-central1',
117+
runtime: 'nodejs8',
116118
function: 'func1',
117119
availableMemoryMb: 1024,
118120
timeout: '60s',
@@ -147,6 +149,7 @@ describe('CompileFunctions', () => {
147149
name: 'my-service-dev-func1',
148150
properties: {
149151
location: 'us-central1',
152+
runtime: 'nodejs8',
150153
function: 'func1',
151154
availableMemoryMb: 1024,
152155
timeout: '60s',
@@ -181,6 +184,7 @@ describe('CompileFunctions', () => {
181184
name: 'my-service-dev-func1',
182185
properties: {
183186
location: 'us-central1',
187+
runtime: 'nodejs8',
184188
function: 'func1',
185189
availableMemoryMb: 256,
186190
timeout: '120s',
@@ -215,6 +219,7 @@ describe('CompileFunctions', () => {
215219
name: 'my-service-dev-func1',
216220
properties: {
217221
location: 'us-central1',
222+
runtime: 'nodejs8',
218223
function: 'func1',
219224
availableMemoryMb: 256,
220225
timeout: '120s',
@@ -251,6 +256,7 @@ describe('CompileFunctions', () => {
251256
name: 'my-service-dev-func1',
252257
properties: {
253258
location: 'us-central1',
259+
runtime: 'nodejs8',
254260
function: 'func1',
255261
availableMemoryMb: 256,
256262
timeout: '60s',
@@ -289,6 +295,7 @@ describe('CompileFunctions', () => {
289295
name: 'my-service-dev-func1',
290296
properties: {
291297
location: 'us-central1',
298+
runtime: 'nodejs8',
292299
function: 'func1',
293300
availableMemoryMb: 256,
294301
timeout: '60s',
@@ -331,6 +338,7 @@ describe('CompileFunctions', () => {
331338
name: 'my-service-dev-func1',
332339
properties: {
333340
location: 'us-central1',
341+
runtime: 'nodejs8',
334342
function: 'func1',
335343
availableMemoryMb: 256,
336344
timeout: '60s',
@@ -367,6 +375,7 @@ describe('CompileFunctions', () => {
367375
name: 'my-service-dev-func1',
368376
properties: {
369377
location: 'us-central1',
378+
runtime: 'nodejs8',
370379
function: 'func1',
371380
availableMemoryMb: 256,
372381
timeout: '60s',
@@ -418,6 +427,7 @@ describe('CompileFunctions', () => {
418427
name: 'my-service-dev-func1',
419428
properties: {
420429
location: 'us-central1',
430+
runtime: 'nodejs8',
421431
function: 'func1',
422432
availableMemoryMb: 256,
423433
timeout: '60s',
@@ -435,6 +445,7 @@ describe('CompileFunctions', () => {
435445
name: 'my-service-dev-func2',
436446
properties: {
437447
location: 'us-central1',
448+
runtime: 'nodejs8',
438449
function: 'func2',
439450
availableMemoryMb: 256,
440451
timeout: '60s',

0 commit comments

Comments
 (0)