Skip to content

Commit 8babdf9

Browse files
authored
Merge pull request #114 from PatrickHeneise/feat/nodejs8-runtime
feat: nodejs8 runtime
2 parents 99f2b43 + db9c65a commit 8babdf9

File tree

4 files changed

+25
-2
lines changed

4 files changed

+25
-2
lines changed

package/lib/compileFunctions.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,20 @@ module.exports = {
2626

2727
const funcTemplate = getFunctionTemplate(
2828
funcObject,
29-
this.options.region,
29+
this.serverless.service.provider.region,
3030
`gs://${
31-
this.serverless.service.provider.deploymentBucketName
31+
this.serverless.service.provider.deploymentBucketName
3232
}/${this.serverless.service.package.artifactFilePath}`);
3333

3434
funcTemplate.properties.availableMemoryMb = _.get(funcObject, 'memorySize')
3535
|| _.get(this, 'serverless.service.provider.memorySize')
3636
|| 256;
37+
funcTemplate.properties.location = _.get(funcObject, 'location')
38+
|| _.get(this, 'serverless.service.provider.region')
39+
|| 'us-central1';
40+
funcTemplate.properties.runtime = _.get(funcObject, 'runtime')
41+
|| _.get(this, 'serverless.service.provider.runtime')
42+
|| 'nodejs8';
3743
funcTemplate.properties.timeout = _.get(funcObject, 'timeout')
3844
|| _.get(this, 'serverless.service.provider.timeout')
3945
|| '60s';
@@ -116,6 +122,7 @@ const getFunctionTemplate = (funcObject, region, sourceArchiveUrl) => { //eslint
116122
properties: {
117123
location: region,
118124
availableMemoryMb: 256,
125+
runtime: 'nodejs8',
119126
timeout: '60s',
120127
function: funcObject.handler,
121128
sourceArchiveUrl,

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',

shared/utils.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ module.exports = {
99
|| 'dev';
1010
this.options.region = _.get(this, 'options.region')
1111
|| 'us-central1';
12+
this.options.runtime = _.get(this, 'options.runtime')
13+
|| 'nodejs8';
1214

1315
return BbPromise.resolve();
1416
},

shared/utils.test.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,18 @@ describe('Utils', () => {
2020
.setDefaults().then(() => {
2121
expect(googleCommand.options.stage).toEqual('dev');
2222
expect(googleCommand.options.region).toEqual('us-central1');
23+
expect(googleCommand.options.runtime).toEqual('nodejs8');
2324
}));
2425

2526
it('should set the options when they are provided', () => {
2627
googleCommand.options.stage = 'my-stage';
2728
googleCommand.options.region = 'my-region';
29+
googleCommand.options.runtime = 'nodejs6';
2830

2931
return googleCommand.setDefaults().then(() => {
3032
expect(googleCommand.options.stage).toEqual('my-stage');
3133
expect(googleCommand.options.region).toEqual('my-region');
34+
expect(googleCommand.options.runtime).toEqual('nodejs6');
3235
});
3336
});
3437
});

0 commit comments

Comments
 (0)