Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions package/lib/compileFunctions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
34 changes: 34 additions & 0 deletions package/lib/compileFunctions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,20 @@ describe('CompileFunctions', () => {
},
],
},
func3: {
handler: 'func3',
events: [
{
event: {
eventType: 'foo',
resource: 'some-resource',
failurePolicy: {
retry: {},
},
},
},
],
},
};

const compiledResources = [
Expand Down Expand Up @@ -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(() => {
Expand Down