Skip to content

Commit 6404a47

Browse files
committed
feat: adding support for failure policy
following serverless#132
1 parent 7cd25ea commit 6404a47

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

package/lib/compileFunctions.js

+2
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

+35
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)