From c6d06b5a6055f8611f13ccc151a6fa05ba76e9ef Mon Sep 17 00:00:00 2001 From: Patrick Housley Date: Fri, 2 Nov 2018 08:29:27 -0500 Subject: [PATCH] Adding support for failure policy --- package/lib/compileFunctions.js | 2 ++ package/lib/compileFunctions.test.js | 34 ++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/package/lib/compileFunctions.js b/package/lib/compileFunctions.js index ec4ca27..5ccb51b 100644 --- a/package/lib/compileFunctions.js +++ b/package/lib/compileFunctions.js @@ -69,11 +69,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 4cfde55..151ea84 100644 --- a/package/lib/compileFunctions.test.js +++ b/package/lib/compileFunctions.test.js @@ -499,6 +499,20 @@ describe('CompileFunctions', () => { }, ], }, + func3: { + handler: 'func3', + events: [ + { + event: { + eventType: 'foo', + resource: 'some-resource', + failurePolicy: { + retry: {}, + }, + }, + }, + ], + }, }; const compiledResources = [ @@ -537,6 +551,26 @@ describe('CompileFunctions', () => { labels: {}, }, }, + { + type: 'cloudfunctions.v1beta2.function', + name: 'my-service-dev-func3', + properties: { + location: 'us-central1', + runtime: 'nodejs8', + function: '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(() => {