From 8d8d4f799b00ca74a27a3f850306174aede6eae3 Mon Sep 17 00:00:00 2001 From: Daniel Young Lee Date: Wed, 30 Oct 2024 10:35:56 -0700 Subject: [PATCH 1/2] Print cloudfunctions.net URL instead of run.app URL for 2nd Gen functions. --- src/deploy/functions/backend.spec.ts | 2 ++ src/deploy/functions/release/fabricator.ts | 2 +- src/gcp/cloudfunctionsv2.spec.ts | 20 +++++++++++--------- src/gcp/cloudfunctionsv2.ts | 2 ++ 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/deploy/functions/backend.spec.ts b/src/deploy/functions/backend.spec.ts index 522505b9cc3..153fb2eb61b 100644 --- a/src/deploy/functions/backend.spec.ts +++ b/src/deploy/functions/backend.spec.ts @@ -53,6 +53,7 @@ describe("Backend", () => { }, }; const RUN_URI = "https://id-nonce-region-project.run.app"; + const GCF_URL = "https://region-project.cloudfunctions.net/id"; const HAVE_CLOUD_FUNCTION_V2: gcfV2.OutputCloudFunction = { ...CLOUD_FUNCTION_V2, serviceConfig: { @@ -61,6 +62,7 @@ describe("Backend", () => { availableCpu: "1", maxInstanceRequestConcurrency: 80, }, + url: GCF_URL, state: "ACTIVE", updateTime: new Date(), }; diff --git a/src/deploy/functions/release/fabricator.ts b/src/deploy/functions/release/fabricator.ts index b755897285b..cf97308b4a4 100644 --- a/src/deploy/functions/release/fabricator.ts +++ b/src/deploy/functions/release/fabricator.ts @@ -394,7 +394,7 @@ export class Fabricator { }); } - endpoint.uri = resultFunction.serviceConfig?.uri; + endpoint.uri = resultFunction.url; const serviceName = resultFunction.serviceConfig?.service; endpoint.runServiceId = utils.last(serviceName?.split("/")); if (!serviceName) { diff --git a/src/gcp/cloudfunctionsv2.spec.ts b/src/gcp/cloudfunctionsv2.spec.ts index ffe68467fff..f5d86480f09 100644 --- a/src/gcp/cloudfunctionsv2.spec.ts +++ b/src/gcp/cloudfunctionsv2.spec.ts @@ -49,12 +49,14 @@ describe("cloudfunctionsv2", () => { }; const RUN_URI = "https://id-nonce-region-project.run.app"; + const GCF_URL = "https://region-project.cloudfunctions.net/id"; const HAVE_CLOUD_FUNCTION_V2: cloudfunctionsv2.OutputCloudFunction = { ...CLOUD_FUNCTION_V2, serviceConfig: { service: "service", uri: RUN_URI, }, + url: GCF_URL, state: "ACTIVE", updateTime: new Date(), }; @@ -408,7 +410,7 @@ describe("cloudfunctionsv2", () => { ...ENDPOINT, httpsTrigger: {}, platform: "gcfv2", - uri: RUN_URI, + uri: GCF_URL, }); }); @@ -425,7 +427,7 @@ describe("cloudfunctionsv2", () => { ...ENDPOINT, httpsTrigger: {}, platform: "gcfv2", - uri: RUN_URI, + uri: GCF_URL, runServiceId: "service-id", }); }); @@ -596,7 +598,7 @@ describe("cloudfunctionsv2", () => { ...ENDPOINT, taskQueueTrigger: {}, platform: "gcfv2", - uri: RUN_URI, + uri: GCF_URL, labels: { "deployment-taskqueue": "true" }, }); }); @@ -613,7 +615,7 @@ describe("cloudfunctionsv2", () => { eventType: events.v1.BEFORE_CREATE_EVENT, }, platform: "gcfv2", - uri: RUN_URI, + uri: GCF_URL, labels: { "deployment-blocking": "before-create" }, }); }); @@ -630,7 +632,7 @@ describe("cloudfunctionsv2", () => { eventType: events.v1.BEFORE_SIGN_IN_EVENT, }, platform: "gcfv2", - uri: RUN_URI, + uri: GCF_URL, labels: { "deployment-blocking": "before-sign-in" }, }); }); @@ -668,7 +670,7 @@ describe("cloudfunctionsv2", () => { ...ENDPOINT, platform: "gcfv2", httpsTrigger: {}, - uri: RUN_URI, + uri: GCF_URL, ...extraFields, serviceAccount: "inlined@google.com", vpc, @@ -703,7 +705,7 @@ describe("cloudfunctionsv2", () => { ).to.deep.equal({ ...ENDPOINT, platform: "gcfv2", - uri: RUN_URI, + uri: GCF_URL, httpsTrigger: {}, ...extraFields, }); @@ -721,7 +723,7 @@ describe("cloudfunctionsv2", () => { ).to.deep.equal({ ...ENDPOINT, platform: "gcfv2", - uri: RUN_URI, + uri: GCF_URL, httpsTrigger: {}, labels: { ...ENDPOINT.labels, @@ -744,7 +746,7 @@ describe("cloudfunctionsv2", () => { ).to.deep.equal({ ...ENDPOINT, platform: "gcfv2", - uri: RUN_URI, + uri: GCF_URL, httpsTrigger: {}, labels: { ...ENDPOINT.labels, diff --git a/src/gcp/cloudfunctionsv2.ts b/src/gcp/cloudfunctionsv2.ts index 82f14bce6fb..af1cb92984a 100644 --- a/src/gcp/cloudfunctionsv2.ts +++ b/src/gcp/cloudfunctionsv2.ts @@ -166,6 +166,7 @@ export type OutputCloudFunction = CloudFunctionBase & { state: FunctionState; updateTime: Date; serviceConfig?: RequireKeys; + url: string; }; export type InputCloudFunction = CloudFunctionBase & { @@ -781,6 +782,7 @@ export function endpointFromFunction(gcfFunction: OutputCloudFunction): backend. endpoint.runServiceId = utils.last(serviceName.split("/")); } } + proto.renameIfPresent(endpoint, gcfFunction, "uri", "url"); endpoint.codebase = gcfFunction.labels?.[CODEBASE_LABEL] || projectConfig.DEFAULT_CODEBASE; if (gcfFunction.labels?.[HASH_LABEL]) { endpoint.hash = gcfFunction.labels[HASH_LABEL]; From ab98269a6625eade4402bdc61f163e669163c1ad Mon Sep 17 00:00:00 2001 From: Daniel Young Lee Date: Wed, 20 Nov 2024 13:14:58 -0800 Subject: [PATCH 2/2] Fix more tests. --- src/deploy/functions/backend.spec.ts | 3 +-- src/gcp/cloudfunctionsv2.spec.ts | 5 +++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/deploy/functions/backend.spec.ts b/src/deploy/functions/backend.spec.ts index 153fb2eb61b..b383344b6a7 100644 --- a/src/deploy/functions/backend.spec.ts +++ b/src/deploy/functions/backend.spec.ts @@ -52,13 +52,12 @@ describe("Backend", () => { maxInstanceRequestConcurrency: 80, }, }; - const RUN_URI = "https://id-nonce-region-project.run.app"; const GCF_URL = "https://region-project.cloudfunctions.net/id"; const HAVE_CLOUD_FUNCTION_V2: gcfV2.OutputCloudFunction = { ...CLOUD_FUNCTION_V2, serviceConfig: { service: "service", - uri: RUN_URI, + uri: GCF_URL, availableCpu: "1", maxInstanceRequestConcurrency: 80, }, diff --git a/src/gcp/cloudfunctionsv2.spec.ts b/src/gcp/cloudfunctionsv2.spec.ts index f5d86480f09..4d3b89eab35 100644 --- a/src/gcp/cloudfunctionsv2.spec.ts +++ b/src/gcp/cloudfunctionsv2.spec.ts @@ -436,7 +436,7 @@ describe("cloudfunctionsv2", () => { let want: backend.Endpoint = { ...ENDPOINT, platform: "gcfv2", - uri: RUN_URI, + uri: GCF_URL, eventTrigger: { eventType: events.v2.PUBSUB_PUBLISH_EVENT, eventFilters: { topic: "projects/p/topics/t" }, @@ -563,7 +563,7 @@ describe("cloudfunctionsv2", () => { const want: backend.Endpoint = { ...ENDPOINT, platform: "gcfv2", - uri: RUN_URI, + uri: GCF_URL, eventTrigger: { eventType: "com.custom.event", eventFilters: { customattr: "customvalue" }, @@ -763,6 +763,7 @@ describe("cloudfunctionsv2", () => { ...ENDPOINT, platform: "gcfv2", httpsTrigger: {}, + uri: GCF_URL, }; delete expectedEndpoint.runServiceId; expect(