Skip to content

Commit 6c0e2ff

Browse files
author
Patrick Housley
committed
Adding support for failure policy
1 parent 39f4d83 commit 6c0e2ff

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

package/lib/compileFunctions.js

+2
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,13 @@ module.exports = {
6969
const type = funcObject.events[0].event.eventType;
7070
const path = funcObject.events[0].event.path; //eslint-disable-line
7171
const resource = funcObject.events[0].event.resource;
72+
const failurePolicy = funcObject.events[0].event.failurePolicy
7273

7374
funcTemplate.properties.eventTrigger = {};
7475
funcTemplate.properties.eventTrigger.eventType = type;
7576
if (path) funcTemplate.properties.eventTrigger.path = path;
7677
funcTemplate.properties.eventTrigger.resource = resource;
78+
if (failurePolicy) funcTemplate.properties.eventTrigger.failurePolicy = failurePolicy;
7779
}
7880

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

package/lib/compileFunctions.test.js

+34
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,20 @@ describe('CompileFunctions', () => {
499499
},
500500
],
501501
},
502+
func3: {
503+
handler: 'func3',
504+
events: [
505+
{
506+
event: {
507+
eventType: 'foo',
508+
resource: 'some-resource',
509+
failurePolicy: {
510+
retry: {},
511+
},
512+
},
513+
},
514+
],
515+
},
502516
};
503517

504518
const compiledResources = [
@@ -537,6 +551,26 @@ describe('CompileFunctions', () => {
537551
labels: {},
538552
},
539553
},
554+
{
555+
type: 'cloudfunctions.v1beta2.function',
556+
name: 'my-service-dev-func3',
557+
properties: {
558+
location: 'us-central1',
559+
runtime: 'nodejs8',
560+
function: 'func3',
561+
availableMemoryMb: 256,
562+
timeout: '60s',
563+
sourceArchiveUrl: 'gs://sls-my-service-dev-12345678/some-path/artifact.zip',
564+
eventTrigger: {
565+
eventType: 'foo',
566+
resource: 'some-resource',
567+
failurePolicy: {
568+
retry: {},
569+
},
570+
},
571+
labels: {},
572+
},
573+
},
540574
];
541575

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

0 commit comments

Comments
 (0)