Skip to content

Commit

Permalink
Merge pull request #114 from PatrickHeneise/feat/nodejs8-runtime
Browse files Browse the repository at this point in the history
feat: nodejs8 runtime
  • Loading branch information
pmuens committed Aug 13, 2018
2 parents 99f2b43 + db9c65a commit 8babdf9
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
11 changes: 9 additions & 2 deletions package/lib/compileFunctions.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,20 @@ module.exports = {

const funcTemplate = getFunctionTemplate(
funcObject,
this.options.region,
this.serverless.service.provider.region,
`gs://${
this.serverless.service.provider.deploymentBucketName
this.serverless.service.provider.deploymentBucketName
}/${this.serverless.service.package.artifactFilePath}`);

funcTemplate.properties.availableMemoryMb = _.get(funcObject, 'memorySize')
|| _.get(this, 'serverless.service.provider.memorySize')
|| 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')
|| _.get(this, 'serverless.service.provider.timeout')
|| '60s';
Expand Down Expand Up @@ -116,6 +122,7 @@ const getFunctionTemplate = (funcObject, region, sourceArchiveUrl) => { //eslint
properties: {
location: region,
availableMemoryMb: 256,
runtime: 'nodejs8',
timeout: '60s',
function: funcObject.handler,
sourceArchiveUrl,
Expand Down
11 changes: 11 additions & 0 deletions package/lib/compileFunctions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ describe('CompileFunctions', () => {
func1: {
handler: 'func1',
memorySize: 1024,
runtime: 'nodejs8',
events: [
{ http: 'foo' },
],
Expand All @@ -113,6 +114,7 @@ describe('CompileFunctions', () => {
name: 'my-service-dev-func1',
properties: {
location: 'us-central1',
runtime: 'nodejs8',
function: 'func1',
availableMemoryMb: 1024,
timeout: '60s',
Expand Down Expand Up @@ -147,6 +149,7 @@ describe('CompileFunctions', () => {
name: 'my-service-dev-func1',
properties: {
location: 'us-central1',
runtime: 'nodejs8',
function: 'func1',
availableMemoryMb: 1024,
timeout: '60s',
Expand Down Expand Up @@ -181,6 +184,7 @@ describe('CompileFunctions', () => {
name: 'my-service-dev-func1',
properties: {
location: 'us-central1',
runtime: 'nodejs8',
function: 'func1',
availableMemoryMb: 256,
timeout: '120s',
Expand Down Expand Up @@ -215,6 +219,7 @@ describe('CompileFunctions', () => {
name: 'my-service-dev-func1',
properties: {
location: 'us-central1',
runtime: 'nodejs8',
function: 'func1',
availableMemoryMb: 256,
timeout: '120s',
Expand Down Expand Up @@ -251,6 +256,7 @@ describe('CompileFunctions', () => {
name: 'my-service-dev-func1',
properties: {
location: 'us-central1',
runtime: 'nodejs8',
function: 'func1',
availableMemoryMb: 256,
timeout: '60s',
Expand Down Expand Up @@ -289,6 +295,7 @@ describe('CompileFunctions', () => {
name: 'my-service-dev-func1',
properties: {
location: 'us-central1',
runtime: 'nodejs8',
function: 'func1',
availableMemoryMb: 256,
timeout: '60s',
Expand Down Expand Up @@ -331,6 +338,7 @@ describe('CompileFunctions', () => {
name: 'my-service-dev-func1',
properties: {
location: 'us-central1',
runtime: 'nodejs8',
function: 'func1',
availableMemoryMb: 256,
timeout: '60s',
Expand Down Expand Up @@ -367,6 +375,7 @@ describe('CompileFunctions', () => {
name: 'my-service-dev-func1',
properties: {
location: 'us-central1',
runtime: 'nodejs8',
function: 'func1',
availableMemoryMb: 256,
timeout: '60s',
Expand Down Expand Up @@ -418,6 +427,7 @@ describe('CompileFunctions', () => {
name: 'my-service-dev-func1',
properties: {
location: 'us-central1',
runtime: 'nodejs8',
function: 'func1',
availableMemoryMb: 256,
timeout: '60s',
Expand All @@ -435,6 +445,7 @@ describe('CompileFunctions', () => {
name: 'my-service-dev-func2',
properties: {
location: 'us-central1',
runtime: 'nodejs8',
function: 'func2',
availableMemoryMb: 256,
timeout: '60s',
Expand Down
2 changes: 2 additions & 0 deletions shared/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ module.exports = {
|| 'dev';
this.options.region = _.get(this, 'options.region')
|| 'us-central1';
this.options.runtime = _.get(this, 'options.runtime')
|| 'nodejs8';

return BbPromise.resolve();
},
Expand Down
3 changes: 3 additions & 0 deletions shared/utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,18 @@ describe('Utils', () => {
.setDefaults().then(() => {
expect(googleCommand.options.stage).toEqual('dev');
expect(googleCommand.options.region).toEqual('us-central1');
expect(googleCommand.options.runtime).toEqual('nodejs8');
}));

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

return googleCommand.setDefaults().then(() => {
expect(googleCommand.options.stage).toEqual('my-stage');
expect(googleCommand.options.region).toEqual('my-region');
expect(googleCommand.options.runtime).toEqual('nodejs6');
});
});
});
Expand Down

0 comments on commit 8babdf9

Please sign in to comment.