From cc87c98dd89299652749058ac4de67fb65fbf7ae Mon Sep 17 00:00:00 2001 From: Alex Pascal Date: Wed, 4 May 2022 11:40:02 -0700 Subject: [PATCH] Added support for calling Eventarc emulator --- src/eventarc/eventarc-client-internal.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/eventarc/eventarc-client-internal.ts b/src/eventarc/eventarc-client-internal.ts index e265480024..ce02967c93 100644 --- a/src/eventarc/eventarc-client-internal.ts +++ b/src/eventarc/eventarc-client-internal.ts @@ -102,7 +102,7 @@ export class EventarcApiClient { } const request: HttpRequestConfig = { method: 'POST', - url: `${EVENTARC_API}/${channel}:publishEvents`, + url: `${this.getEventarcHost()}/${channel}:publishEvents`, data: JSON.stringify({ events }), }; return this.sendRequest(request); @@ -153,4 +153,8 @@ export class EventarcApiClient { const projectId = await this.getProjectId(); return `projects/${projectId}/locations/${location}/channels/${channelId}`; } + + private getEventarcHost(): string { + return process.env.CLOUD_EVENTARC_EMULATOR_HOST ?? EVENTARC_API; + } }