From 7cd25ea21e37b06938a8a210472b4611b348fde7 Mon Sep 17 00:00:00 2001 From: EthanChou Date: Wed, 22 Jul 2020 12:45:22 +0800 Subject: [PATCH 1/2] revise package.json --- package.json | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 62ff5c9..96dc93f 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,13 @@ { - "name": "serverless-google-cloudfunctions", + "name": "@alleypin/serverless-google-cloudfunctions", "version": "3.1.0", - "description": "Provider plugin for the Serverless Framework v1.x which adds support for Google Cloud Functions.", - "author": "serverless.com", - "repository": "serverless/serverless-google-cloudfunctions", - "homepage": "https://github.com/serverless/serverless-google-cloudfunctions", + "description": "Modified by AlleyPin, Provider plugin for the Serverless Framework v1.x which adds support for Google Cloud Functions.", + "author": "alleypin.com", + "repository": { + "type": "git", + "url": "git+https://github.com/AlleyPin/serverless-google-cloudfunctions.git" + }, + "homepage": "https://github.com/AlleyPin/serverless-google-cloudfunctions.git", "keywords": [ "serverless", "serverless framework", @@ -74,5 +77,12 @@ "prettify:updated": "pipe-git-updated --ext=css --ext=html --ext=js --ext=json --ext=md --ext=yaml --ext=yml -- prettier --write", "test": "jest" }, - "license": "MIT" + "license": "MIT", + "bugs": { + "url": "https://github.com/AlleyPin/serverless-google-cloudfunctions/issues" + }, + "main": "index.js", + "directories": { + "test": "test" + } } From 6404a470e688d5ad6edf135cd3399364346d3b36 Mon Sep 17 00:00:00 2001 From: EthanChou Date: Wed, 22 Jul 2020 13:18:51 +0800 Subject: [PATCH 2/2] feat: adding support for failure policy following https://github.com/serverless/serverless-google-cloudfunctions/pull/132 --- package/lib/compileFunctions.js | 2 ++ package/lib/compileFunctions.test.js | 35 ++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/package/lib/compileFunctions.js b/package/lib/compileFunctions.js index d24afbf..37ff4d7 100644 --- a/package/lib/compileFunctions.js +++ b/package/lib/compileFunctions.js @@ -88,11 +88,13 @@ module.exports = { const type = funcObject.events[0].event.eventType; const path = funcObject.events[0].event.path; //eslint-disable-line const resource = funcObject.events[0].event.resource; + const failurePolicy = funcObject.events[0].event.failurePolicy; funcTemplate.properties.eventTrigger = {}; funcTemplate.properties.eventTrigger.eventType = type; if (path) funcTemplate.properties.eventTrigger.path = path; funcTemplate.properties.eventTrigger.resource = resource; + if (failurePolicy) funcTemplate.properties.eventTrigger.failurePolicy = failurePolicy; } this.serverless.service.provider.compiledConfigurationTemplate.resources.push(funcTemplate); diff --git a/package/lib/compileFunctions.test.js b/package/lib/compileFunctions.test.js index cfdc6f4..9ee810f 100644 --- a/package/lib/compileFunctions.test.js +++ b/package/lib/compileFunctions.test.js @@ -568,6 +568,20 @@ describe('CompileFunctions', () => { }, ], }, + func3: { + handler: 'func3', + events: [ + { + event: { + eventType: 'foo', + resource: 'some-resource', + failurePolicy: { + retry: {}, + }, + }, + }, + ], + }, }; const compiledResources = [ @@ -608,6 +622,27 @@ describe('CompileFunctions', () => { labels: {}, }, }, + { + type: 'gcp-types/cloudfunctions-v1:projects.locations.functions', + name: 'my-service-dev-func3', + properties: { + entryPoint: 'func3', + parent: 'projects/myProject/locations/us-central1', + runtime: 'nodejs8', + function: 'my-service-dev-func3', + availableMemoryMb: 256, + timeout: '60s', + sourceArchiveUrl: 'gs://sls-my-service-dev-12345678/some-path/artifact.zip', + eventTrigger: { + eventType: 'foo', + resource: 'some-resource', + failurePolicy: { + retry: {}, + }, + }, + labels: {}, + }, + }, ]; return googlePackage.compileFunctions().then(() => {