Skip to content

Commit 58f05dc

Browse files
committed
Loose ends on endpoint annotation on event triggers.
1 parent 6e3a026 commit 58f05dc

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

src/cloud-functions.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ export function makeCloudFunction<EventData>({
446446
Object.defineProperty(cloudFunction, '__endpoint', {
447447
get: () => {
448448
if (triggerResource() == null) {
449-
return undefined;
449+
return {};
450450
}
451451

452452
const endpoint: ManifestEndpoint = {
@@ -474,6 +474,19 @@ export function makeCloudFunction<EventData>({
474474
},
475475
});
476476

477+
if (options.schedule) {
478+
cloudFunction.__requiredAPIs = [
479+
{
480+
api: 'pubsub.googleapis.com',
481+
reason: 'Needed for v1 scheduled functions.',
482+
},
483+
{
484+
api: 'cloudscheduler.googleapis.com',
485+
reason: 'Needed for v1 scheduled functions.',
486+
},
487+
];
488+
}
489+
477490
cloudFunction.run = handler || contextOnlyHandler;
478491
return cloudFunction;
479492
}
@@ -609,15 +622,14 @@ export function optionsToEndpoint(
609622
'serviceAccount',
610623
(sa) => sa
611624
);
612-
if (options.vpcConnector) {
613-
const vpc: ManifestEndpoint['vpc'] = { connector: options.vpcConnector };
625+
if (options?.vpcConnector) {
626+
endpoint.vpc = { connector: options.vpcConnector };
614627
convertIfPresent(
615-
vpc,
628+
endpoint.vpc,
616629
options,
617630
'egressSettings',
618631
'vpcConnectorEgressSettings'
619632
);
620-
endpoint.vpc = vpc;
621633
}
622634
convertIfPresent(endpoint, options, 'availableMemoryMb', 'memory', (mem) => {
623635
const memoryLookup = {

0 commit comments

Comments
 (0)