Skip to content

Commit c3ba0b5

Browse files
authored
Merge pull request #1 from AlleyPin/feat-adding-support-for-failure-policy
Feat adding support for failure policy
2 parents d0d9a41 + 6404a47 commit c3ba0b5

File tree

3 files changed

+53
-6
lines changed

3 files changed

+53
-6
lines changed

package.json

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
{
2-
"name": "serverless-google-cloudfunctions",
2+
"name": "@alleypin/serverless-google-cloudfunctions",
33
"version": "3.1.0",
4-
"description": "Provider plugin for the Serverless Framework v1.x which adds support for Google Cloud Functions.",
5-
"author": "serverless.com",
6-
"repository": "serverless/serverless-google-cloudfunctions",
7-
"homepage": "https://github.com/serverless/serverless-google-cloudfunctions",
4+
"description": "Modified by AlleyPin, Provider plugin for the Serverless Framework v1.x which adds support for Google Cloud Functions.",
5+
"author": "alleypin.com",
6+
"repository": {
7+
"type": "git",
8+
"url": "git+https://github.com/AlleyPin/serverless-google-cloudfunctions.git"
9+
},
10+
"homepage": "https://github.com/AlleyPin/serverless-google-cloudfunctions.git",
811
"keywords": [
912
"serverless",
1013
"serverless framework",
@@ -74,5 +77,12 @@
7477
"prettify:updated": "pipe-git-updated --ext=css --ext=html --ext=js --ext=json --ext=md --ext=yaml --ext=yml -- prettier --write",
7578
"test": "jest"
7679
},
77-
"license": "MIT"
80+
"license": "MIT",
81+
"bugs": {
82+
"url": "https://github.com/AlleyPin/serverless-google-cloudfunctions/issues"
83+
},
84+
"main": "index.js",
85+
"directories": {
86+
"test": "test"
87+
}
7888
}

package/lib/compileFunctions.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,13 @@ module.exports = {
8888
const type = funcObject.events[0].event.eventType;
8989
const path = funcObject.events[0].event.path; //eslint-disable-line
9090
const resource = funcObject.events[0].event.resource;
91+
const failurePolicy = funcObject.events[0].event.failurePolicy;
9192

9293
funcTemplate.properties.eventTrigger = {};
9394
funcTemplate.properties.eventTrigger.eventType = type;
9495
if (path) funcTemplate.properties.eventTrigger.path = path;
9596
funcTemplate.properties.eventTrigger.resource = resource;
97+
if (failurePolicy) funcTemplate.properties.eventTrigger.failurePolicy = failurePolicy;
9698
}
9799

98100
this.serverless.service.provider.compiledConfigurationTemplate.resources.push(funcTemplate);

package/lib/compileFunctions.test.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,20 @@ describe('CompileFunctions', () => {
568568
},
569569
],
570570
},
571+
func3: {
572+
handler: 'func3',
573+
events: [
574+
{
575+
event: {
576+
eventType: 'foo',
577+
resource: 'some-resource',
578+
failurePolicy: {
579+
retry: {},
580+
},
581+
},
582+
},
583+
],
584+
},
571585
};
572586

573587
const compiledResources = [
@@ -608,6 +622,27 @@ describe('CompileFunctions', () => {
608622
labels: {},
609623
},
610624
},
625+
{
626+
type: 'gcp-types/cloudfunctions-v1:projects.locations.functions',
627+
name: 'my-service-dev-func3',
628+
properties: {
629+
entryPoint: 'func3',
630+
parent: 'projects/myProject/locations/us-central1',
631+
runtime: 'nodejs8',
632+
function: 'my-service-dev-func3',
633+
availableMemoryMb: 256,
634+
timeout: '60s',
635+
sourceArchiveUrl: 'gs://sls-my-service-dev-12345678/some-path/artifact.zip',
636+
eventTrigger: {
637+
eventType: 'foo',
638+
resource: 'some-resource',
639+
failurePolicy: {
640+
retry: {},
641+
},
642+
},
643+
labels: {},
644+
},
645+
},
611646
];
612647

613648
return googlePackage.compileFunctions().then(() => {

0 commit comments

Comments
 (0)