Skip to content

Commit d15b253

Browse files
committed
Change default endponit cfg for v1.
1 parent c0925c1 commit d15b253

File tree

11 files changed

+36
-9
lines changed

11 files changed

+36
-9
lines changed

spec/fixtures.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { ManifestEndpoint } from "../src/runtime/manifest";
2+
import { RESET_VALUE } from "../src/common/options";
3+
4+
export const MINIMAL_ENDPOINT: Partial<ManifestEndpoint> = {
5+
availableMemoryMb: RESET_VALUE,
6+
concurrency: RESET_VALUE,
7+
ingressSettings: RESET_VALUE,
8+
maxInstances: RESET_VALUE,
9+
minInstances: RESET_VALUE,
10+
serviceAccountEmail: RESET_VALUE,
11+
timeoutSeconds: RESET_VALUE,
12+
vpc: {
13+
connector: RESET_VALUE,
14+
egressSettings: RESET_VALUE,
15+
},
16+
};

spec/v1/providers/fixtures.ts

Whitespace-only changes.

src/runtime/manifest.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ export function stackToWire(stack: ManifestStack): Record<string, unknown> {
143143
*/
144144
export function initEndpoint(...opts: { preserveExternalChanges?: boolean }[]): ManifestEndpoint {
145145
const endpoint: ManifestEndpoint = {};
146-
if (opts.every((opt) => !opt.preserveExternalChanges)) {
146+
if (opts.every((opt) => !opt?.preserveExternalChanges)) {
147147
for (const key of Object.keys(RESETTABLE_OPTIONS)) {
148148
endpoint[key] = RESET_VALUE;
149149
}
@@ -180,7 +180,7 @@ export function initTaskQueueTrigger(
180180
...opts: { preserveExternalChanges?: boolean }[]
181181
): ManifestEndpoint["taskQueueTrigger"] {
182182
let taskQueueTrigger = {};
183-
if (opts.every((opt) => !opt.preserveExternalChanges)) {
183+
if (opts.every((opt) => !opt?.preserveExternalChanges)) {
184184
const retryConfig = {};
185185
for (const key of Object.keys(RESETTABLE_RETRY_CONFIG_OPTIONS)) {
186186
retryConfig[key] = RESET_VALUE;
@@ -222,7 +222,7 @@ function initScheduleTrigger(
222222
...opts: { preserveExternalChanges?: boolean }[]
223223
): ManifestEndpoint["scheduleTrigger"] {
224224
let scheduleTrigger: ManifestEndpoint["scheduleTrigger"] = { schedule };
225-
if (opts.every((opt) => !opt.preserveExternalChanges)) {
225+
if (opts.every((opt) => !opt?.preserveExternalChanges)) {
226226
const retryConfig = {};
227227
for (const key of Object.keys(resetOptions)) {
228228
retryConfig[key] = RESET_VALUE;

src/v2/providers/alerts/alerts.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
// SOFTWARE.
2222

23-
import { ManifestEndpoint } from "../../../runtime/manifest";
23+
import { initEndpoint, ManifestEndpoint } from "../../../runtime/manifest";
2424
import { ResetValue } from "../../../common/options";
2525
import { CloudEvent, CloudFunction } from "../../core";
2626
import { Expression } from "../../../params";
@@ -230,6 +230,7 @@ export function getEndpointAnnotation(
230230
const baseOpts = options.optionsToEndpoint(options.getGlobalOptions());
231231
const specificOpts = options.optionsToEndpoint(opts);
232232
const endpoint: ManifestEndpoint = {
233+
...initEndpoint(options.getGlobalOptions(), opts),
233234
platform: "gcfv2",
234235
...baseOpts,
235236
...specificOpts,

src/v2/providers/database.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import { DataSnapshot } from "../../common/providers/database";
2828
import { normalizePath } from "../../common/utilities/path";
2929
import { PathPattern } from "../../common/utilities/path-pattern";
3030
import { applyChange } from "../../common/utilities/utils";
31-
import { ManifestEndpoint } from "../../runtime/manifest";
31+
import { initEndpoint, ManifestEndpoint } from "../../runtime/manifest";
3232
import { CloudEvent, CloudFunction } from "../core";
3333
import { Expression } from "../../params";
3434
import { wrapTraceContext } from "../trace";
@@ -428,6 +428,7 @@ export function makeEndpoint(
428428
: (eventFilters.instance = instance.getValue());
429429

430430
return {
431+
...initEndpoint(options.getGlobalOptions(), opts),
431432
platform: "gcfv2",
432433
...baseOpts,
433434
...specificOpts,

src/v2/providers/eventarc.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
import { convertIfPresent, copyIfPresent } from "../../common/encoding";
2929
import { ResetValue } from "../../common/options";
30-
import { ManifestEndpoint } from "../../runtime/manifest";
30+
import { initEndpoint, ManifestEndpoint } from "../../runtime/manifest";
3131
import { CloudEvent, CloudFunction } from "../core";
3232
import { wrapTraceContext } from "../trace";
3333
import { Expression } from "../../params";
@@ -199,6 +199,7 @@ export function onCustomEventPublished<T = any>(
199199
const specificOpts = options.optionsToEndpoint(opts);
200200

201201
const endpoint: ManifestEndpoint = {
202+
...initEndpoint(options.getGlobalOptions(), opts),
202203
platform: "gcfv2",
203204
...baseOpts,
204205
...specificOpts,

src/v2/providers/https.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import {
3838
onCallHandler,
3939
Request,
4040
} from "../../common/providers/https";
41-
import { ManifestEndpoint } from "../../runtime/manifest";
41+
import { initEndpoint, ManifestEndpoint } from "../../runtime/manifest";
4242
import * as options from "../options";
4343
import { GlobalOptions, SupportedRegion } from "../options";
4444
import { Expression } from "../../params";
@@ -241,6 +241,7 @@ export function onRequest(
241241
// but optionsToTriggerAnnotations handles both cases.
242242
const specificOpts = options.optionsToEndpoint(opts as options.GlobalOptions);
243243
const endpoint: Partial<ManifestEndpoint> = {
244+
...initEndpoint(options.getGlobalOptions(), opts),
244245
platform: "gcfv2",
245246
...baseOpts,
246247
...specificOpts,
@@ -304,6 +305,7 @@ export function onCall<T = any, Return = any | Promise<any>>(
304305
// but optionsToEndpoint handles both cases.
305306
const specificOpts = options.optionsToEndpoint(opts);
306307
func.__endpoint = {
308+
...initEndpoint(options.getGlobalOptions(), opts),
307309
platform: "gcfv2",
308310
...baseOpts,
309311
...specificOpts,

src/v2/providers/identity.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ import { BlockingFunction } from "../../v1/cloud-functions";
3838
import { wrapTraceContext } from "../trace";
3939
import { Expression } from "../../params";
4040
import * as options from "../options";
41+
import { initEndpoint } from "../../runtime/manifest";
4142

4243
export { AuthUserRecord, AuthBlockingEvent, HttpsError };
4344

@@ -283,6 +284,7 @@ export function beforeOperation(
283284
const baseOptsEndpoint = options.optionsToEndpoint(options.getGlobalOptions());
284285
const specificOptsEndpoint = options.optionsToEndpoint(opts);
285286
func.__endpoint = {
287+
...initEndpoint(options.getGlobalOptions(), opts),
286288
platform: "gcfv2",
287289
...baseOptsEndpoint,
288290
...specificOptsEndpoint,

src/v2/providers/pubsub.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
import { copyIfPresent } from "../../common/encoding";
2929
import { ResetValue } from "../../common/options";
30-
import { ManifestEndpoint } from "../../runtime/manifest";
30+
import { initEndpoint, ManifestEndpoint } from "../../runtime/manifest";
3131
import { CloudEvent, CloudFunction } from "../core";
3232
import { wrapTraceContext } from "../trace";
3333
import { Expression } from "../../params";
@@ -306,6 +306,7 @@ export function onMessagePublished<T = any>(
306306
const specificOpts = options.optionsToEndpoint(opts);
307307

308308
const endpoint: ManifestEndpoint = {
309+
...initEndpoint(options.getGlobalOptions(), opts),
309310
platform: "gcfv2",
310311
...baseOpts,
311312
...specificOpts,

src/v2/providers/remoteConfig.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
// SOFTWARE.
2222

23-
import { ManifestEndpoint } from "../../runtime/manifest";
23+
import { initEndpoint, ManifestEndpoint } from "../../runtime/manifest";
2424
import { CloudEvent, CloudFunction } from "../core";
2525
import { EventHandlerOptions, getGlobalOptions, optionsToEndpoint } from "../options";
2626

@@ -137,6 +137,7 @@ export function onConfigUpdated(
137137
func.run = handler;
138138

139139
const ep: ManifestEndpoint = {
140+
...initEndpoint(getGlobalOptions(), optsOrHandler),
140141
platform: "gcfv2",
141142
...baseOpts,
142143
...specificOpts,

src/v2/providers/scheduler.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { copyIfPresent } from "../../common/encoding";
2626
import { ResetValue } from "../../common/options";
2727
import { timezone } from "../../common/timezone";
2828
import {
29+
initEndpoint,
2930
initV2ScheduleTrigger,
3031
ManifestEndpoint,
3132
ManifestRequiredAPI,
@@ -179,6 +180,7 @@ export function onSchedule(
179180
const specificOptsEndpoint = options.optionsToEndpoint(separatedOpts.opts);
180181

181182
const ep: ManifestEndpoint = {
183+
...initEndpoint(globalOpts, separatedOpts.opts),
182184
platform: "gcfv2",
183185
...baseOptsEndpoint,
184186
...specificOptsEndpoint,

0 commit comments

Comments
 (0)