firebase-tools 12.5.1 → 12.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -130,7 +130,7 @@ function of(...endpoints) {
|
|
|
130
130
|
for (const endpoint of endpoints) {
|
|
131
131
|
bkend.endpoints[endpoint.region] = bkend.endpoints[endpoint.region] || {};
|
|
132
132
|
if (bkend.endpoints[endpoint.region][endpoint.id]) {
|
|
133
|
-
throw new Error("Trying to create a backend with the same
|
|
133
|
+
throw new Error("Trying to create a backend with the same endpoint twice");
|
|
134
134
|
}
|
|
135
135
|
bkend.endpoints[endpoint.region][endpoint.id] = endpoint;
|
|
136
136
|
}
|
|
@@ -95,18 +95,17 @@ class Fabricator {
|
|
|
95
95
|
deployResults.push(result);
|
|
96
96
|
};
|
|
97
97
|
const upserts = [];
|
|
98
|
-
const
|
|
99
|
-
const scraperV2 = new sourceTokenScraper_1.SourceTokenScraper();
|
|
98
|
+
const scraper = new sourceTokenScraper_1.SourceTokenScraper();
|
|
100
99
|
for (const endpoint of changes.endpointsToCreate) {
|
|
101
100
|
this.logOpStart("creating", endpoint);
|
|
102
|
-
upserts.push(handle("create", endpoint, () => this.createEndpoint(endpoint,
|
|
101
|
+
upserts.push(handle("create", endpoint, () => this.createEndpoint(endpoint, scraper)));
|
|
103
102
|
}
|
|
104
103
|
for (const endpoint of changes.endpointsToSkip) {
|
|
105
104
|
utils.logSuccess(this.getLogSuccessMessage("skip", endpoint));
|
|
106
105
|
}
|
|
107
106
|
for (const update of changes.endpointsToUpdate) {
|
|
108
107
|
this.logOpStart("updating", update.endpoint);
|
|
109
|
-
upserts.push(handle("update", update.endpoint, () => this.updateEndpoint(update,
|
|
108
|
+
upserts.push(handle("update", update.endpoint, () => this.updateEndpoint(update, scraper)));
|
|
110
109
|
}
|
|
111
110
|
await utils.allSettled(upserts);
|
|
112
111
|
if (deployResults.find((r) => r.error)) {
|
|
@@ -127,31 +126,31 @@ class Fabricator {
|
|
|
127
126
|
await utils.allSettled(deletes);
|
|
128
127
|
return deployResults;
|
|
129
128
|
}
|
|
130
|
-
async createEndpoint(endpoint,
|
|
129
|
+
async createEndpoint(endpoint, scraper) {
|
|
131
130
|
endpoint.labels = Object.assign(Object.assign({}, endpoint.labels), deploymentTool.labels());
|
|
132
131
|
if (endpoint.platform === "gcfv1") {
|
|
133
|
-
await this.createV1Function(endpoint,
|
|
132
|
+
await this.createV1Function(endpoint, scraper);
|
|
134
133
|
}
|
|
135
134
|
else if (endpoint.platform === "gcfv2") {
|
|
136
|
-
await this.createV2Function(endpoint
|
|
135
|
+
await this.createV2Function(endpoint);
|
|
137
136
|
}
|
|
138
137
|
else {
|
|
139
138
|
(0, functional_1.assertExhaustive)(endpoint.platform);
|
|
140
139
|
}
|
|
141
140
|
await this.setTrigger(endpoint);
|
|
142
141
|
}
|
|
143
|
-
async updateEndpoint(update,
|
|
142
|
+
async updateEndpoint(update, scraper) {
|
|
144
143
|
update.endpoint.labels = Object.assign(Object.assign({}, update.endpoint.labels), deploymentTool.labels());
|
|
145
144
|
if (update.deleteAndRecreate) {
|
|
146
145
|
await this.deleteEndpoint(update.deleteAndRecreate);
|
|
147
|
-
await this.createEndpoint(update.endpoint,
|
|
146
|
+
await this.createEndpoint(update.endpoint, scraper);
|
|
148
147
|
return;
|
|
149
148
|
}
|
|
150
149
|
if (update.endpoint.platform === "gcfv1") {
|
|
151
|
-
await this.updateV1Function(update.endpoint,
|
|
150
|
+
await this.updateV1Function(update.endpoint, scraper);
|
|
152
151
|
}
|
|
153
152
|
else if (update.endpoint.platform === "gcfv2") {
|
|
154
|
-
await this.updateV2Function(update.endpoint
|
|
153
|
+
await this.updateV2Function(update.endpoint);
|
|
155
154
|
}
|
|
156
155
|
else {
|
|
157
156
|
(0, functional_1.assertExhaustive)(update.endpoint.platform);
|
|
@@ -222,7 +221,7 @@ class Fabricator {
|
|
|
222
221
|
.catch(rethrowAs(endpoint, "set invoker"));
|
|
223
222
|
}
|
|
224
223
|
}
|
|
225
|
-
async createV2Function(endpoint
|
|
224
|
+
async createV2Function(endpoint) {
|
|
226
225
|
var _a, _b, _c, _d, _e;
|
|
227
226
|
const storageSource = (_a = this.sources[endpoint.codebase]) === null || _a === void 0 ? void 0 : _a.storage;
|
|
228
227
|
if (!storageSource) {
|
|
@@ -276,9 +275,8 @@ class Fabricator {
|
|
|
276
275
|
while (!resultFunction) {
|
|
277
276
|
resultFunction = await this.functionExecutor
|
|
278
277
|
.run(async () => {
|
|
279
|
-
apiFunction.buildConfig.sourceToken = await scraper.getToken();
|
|
280
278
|
const op = await gcfV2.createFunction(apiFunction);
|
|
281
|
-
return await poller.pollOperation(Object.assign(Object.assign({}, gcfV2PollerOptions), { pollerName: `create-${endpoint.codebase}-${endpoint.region}-${endpoint.id}`, operationResourceName: op.name
|
|
279
|
+
return await poller.pollOperation(Object.assign(Object.assign({}, gcfV2PollerOptions), { pollerName: `create-${endpoint.codebase}-${endpoint.region}-${endpoint.id}`, operationResourceName: op.name }));
|
|
282
280
|
})
|
|
283
281
|
.catch(async (err) => {
|
|
284
282
|
if (err.code === CLOUD_RUN_RESOURCE_EXHAUSTED_CODE) {
|
|
@@ -368,7 +366,7 @@ class Fabricator {
|
|
|
368
366
|
.catch(rethrowAs(endpoint, "set invoker"));
|
|
369
367
|
}
|
|
370
368
|
}
|
|
371
|
-
async updateV2Function(endpoint
|
|
369
|
+
async updateV2Function(endpoint) {
|
|
372
370
|
var _a, _b, _c, _d;
|
|
373
371
|
const storageSource = (_a = this.sources[endpoint.codebase]) === null || _a === void 0 ? void 0 : _a.storage;
|
|
374
372
|
if (!storageSource) {
|
|
@@ -381,9 +379,8 @@ class Fabricator {
|
|
|
381
379
|
}
|
|
382
380
|
const resultFunction = await this.functionExecutor
|
|
383
381
|
.run(async () => {
|
|
384
|
-
apiFunction.buildConfig.sourceToken = await scraper.getToken();
|
|
385
382
|
const op = await gcfV2.updateFunction(apiFunction);
|
|
386
|
-
return await poller.pollOperation(Object.assign(Object.assign({}, gcfV2PollerOptions), { pollerName: `update-${endpoint.codebase}-${endpoint.region}-${endpoint.id}`, operationResourceName: op.name
|
|
383
|
+
return await poller.pollOperation(Object.assign(Object.assign({}, gcfV2PollerOptions), { pollerName: `update-${endpoint.codebase}-${endpoint.region}-${endpoint.id}`, operationResourceName: op.name }));
|
|
387
384
|
}, { retryCodes: [...executor_1.DEFAULT_RETRY_CODES, CLOUD_RUN_RESOURCE_EXHAUSTED_CODE] })
|
|
388
385
|
.catch(rethrowAs(endpoint, "update"));
|
|
389
386
|
endpoint.uri = (_c = resultFunction.serviceConfig) === null || _c === void 0 ? void 0 : _c.uri;
|
|
@@ -5,9 +5,8 @@ const error_1 = require("../../../error");
|
|
|
5
5
|
const functional_1 = require("../../../functional");
|
|
6
6
|
const logger_1 = require("../../../logger");
|
|
7
7
|
class SourceTokenScraper {
|
|
8
|
-
constructor(validDurationMs = 1500000
|
|
8
|
+
constructor(validDurationMs = 1500000) {
|
|
9
9
|
this.tokenValidDurationMs = validDurationMs;
|
|
10
|
-
this.fetchTimeoutMs = fetchTimeoutMs;
|
|
11
10
|
this.promise = new Promise((resolve) => (this.resolve = resolve));
|
|
12
11
|
this.fetchState = "NONE";
|
|
13
12
|
}
|
|
@@ -17,13 +16,7 @@ class SourceTokenScraper {
|
|
|
17
16
|
return undefined;
|
|
18
17
|
}
|
|
19
18
|
else if (this.fetchState === "FETCHING") {
|
|
20
|
-
|
|
21
|
-
setTimeout(() => {
|
|
22
|
-
this.fetchState = "NONE";
|
|
23
|
-
resolve(undefined);
|
|
24
|
-
}, this.fetchTimeoutMs);
|
|
25
|
-
});
|
|
26
|
-
return Promise.race([this.promise, timeout]);
|
|
19
|
+
return this.promise;
|
|
27
20
|
}
|
|
28
21
|
else if (this.fetchState === "VALID") {
|
|
29
22
|
if (this.isTokenExpired()) {
|