Skip to content

Commit

Permalink
Print cloudfunctions.net URL instead of run.app URL for 2nd Gen funct…
Browse files Browse the repository at this point in the history
…ions. (#7887)
  • Loading branch information
taeold authored Nov 20, 2024
1 parent 597a589 commit 2690983
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 14 deletions.
5 changes: 3 additions & 2 deletions src/deploy/functions/backend.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,16 @@ 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,
},
url: GCF_URL,
state: "ACTIVE",
updateTime: new Date(),
};
Expand Down
2 changes: 1 addition & 1 deletion src/deploy/functions/release/fabricator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
25 changes: 14 additions & 11 deletions src/gcp/cloudfunctionsv2.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
};
Expand Down Expand Up @@ -408,7 +410,7 @@ describe("cloudfunctionsv2", () => {
...ENDPOINT,
httpsTrigger: {},
platform: "gcfv2",
uri: RUN_URI,
uri: GCF_URL,
});
});

Expand All @@ -425,7 +427,7 @@ describe("cloudfunctionsv2", () => {
...ENDPOINT,
httpsTrigger: {},
platform: "gcfv2",
uri: RUN_URI,
uri: GCF_URL,
runServiceId: "service-id",
});
});
Expand All @@ -434,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" },
Expand Down Expand Up @@ -561,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" },
Expand Down Expand Up @@ -596,7 +598,7 @@ describe("cloudfunctionsv2", () => {
...ENDPOINT,
taskQueueTrigger: {},
platform: "gcfv2",
uri: RUN_URI,
uri: GCF_URL,
labels: { "deployment-taskqueue": "true" },
});
});
Expand All @@ -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" },
});
});
Expand All @@ -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" },
});
});
Expand Down Expand Up @@ -668,7 +670,7 @@ describe("cloudfunctionsv2", () => {
...ENDPOINT,
platform: "gcfv2",
httpsTrigger: {},
uri: RUN_URI,
uri: GCF_URL,
...extraFields,
serviceAccount: "inlined@google.com",
vpc,
Expand Down Expand Up @@ -703,7 +705,7 @@ describe("cloudfunctionsv2", () => {
).to.deep.equal({
...ENDPOINT,
platform: "gcfv2",
uri: RUN_URI,
uri: GCF_URL,
httpsTrigger: {},
...extraFields,
});
Expand All @@ -721,7 +723,7 @@ describe("cloudfunctionsv2", () => {
).to.deep.equal({
...ENDPOINT,
platform: "gcfv2",
uri: RUN_URI,
uri: GCF_URL,
httpsTrigger: {},
labels: {
...ENDPOINT.labels,
Expand All @@ -744,7 +746,7 @@ describe("cloudfunctionsv2", () => {
).to.deep.equal({
...ENDPOINT,
platform: "gcfv2",
uri: RUN_URI,
uri: GCF_URL,
httpsTrigger: {},
labels: {
...ENDPOINT.labels,
Expand All @@ -761,6 +763,7 @@ describe("cloudfunctionsv2", () => {
...ENDPOINT,
platform: "gcfv2",
httpsTrigger: {},
uri: GCF_URL,
};
delete expectedEndpoint.runServiceId;
expect(
Expand Down
2 changes: 2 additions & 0 deletions src/gcp/cloudfunctionsv2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ export type OutputCloudFunction = CloudFunctionBase & {
state: FunctionState;
updateTime: Date;
serviceConfig?: RequireKeys<ServiceConfig, "service" | "uri">;
url: string;
};

export type InputCloudFunction = CloudFunctionBase & {
Expand Down Expand Up @@ -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];
Expand Down

0 comments on commit 2690983

Please sign in to comment.