Skip to content

Commit 97faebd

Browse files
authored
Revert "Fix issue with mixed v1 and v2 functions deployments (#6293)"
This reverts commit d44e236.
1 parent 42124d7 commit 97faebd

File tree

2 files changed

+20
-56
lines changed

2 files changed

+20
-56
lines changed

src/deploy/functions/release/fabricator.ts

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -130,22 +130,17 @@ export class Fabricator {
130130
};
131131

132132
const upserts: Array<Promise<void>> = [];
133-
const scraperV1 = new SourceTokenScraper();
134-
const scraperV2 = new SourceTokenScraper();
133+
const scraper = new SourceTokenScraper();
135134
for (const endpoint of changes.endpointsToCreate) {
136135
this.logOpStart("creating", endpoint);
137-
upserts.push(
138-
handle("create", endpoint, () => this.createEndpoint(endpoint, scraperV1, scraperV2))
139-
);
136+
upserts.push(handle("create", endpoint, () => this.createEndpoint(endpoint, scraper)));
140137
}
141138
for (const endpoint of changes.endpointsToSkip) {
142139
utils.logSuccess(this.getLogSuccessMessage("skip", endpoint));
143140
}
144141
for (const update of changes.endpointsToUpdate) {
145142
this.logOpStart("updating", update.endpoint);
146-
upserts.push(
147-
handle("update", update.endpoint, () => this.updateEndpoint(update, scraperV1, scraperV2))
148-
);
143+
upserts.push(handle("update", update.endpoint, () => this.updateEndpoint(update, scraper)));
149144
}
150145
await utils.allSettled(upserts);
151146

@@ -172,39 +167,31 @@ export class Fabricator {
172167
return deployResults;
173168
}
174169

175-
async createEndpoint(
176-
endpoint: backend.Endpoint,
177-
scraperV1: SourceTokenScraper,
178-
scraperV2: SourceTokenScraper
179-
): Promise<void> {
170+
async createEndpoint(endpoint: backend.Endpoint, scraper: SourceTokenScraper): Promise<void> {
180171
endpoint.labels = { ...endpoint.labels, ...deploymentTool.labels() };
181172
if (endpoint.platform === "gcfv1") {
182-
await this.createV1Function(endpoint, scraperV1);
173+
await this.createV1Function(endpoint, scraper);
183174
} else if (endpoint.platform === "gcfv2") {
184-
await this.createV2Function(endpoint, scraperV2);
175+
await this.createV2Function(endpoint, scraper);
185176
} else {
186177
assertExhaustive(endpoint.platform);
187178
}
188179

189180
await this.setTrigger(endpoint);
190181
}
191182

192-
async updateEndpoint(
193-
update: planner.EndpointUpdate,
194-
scraperV1: SourceTokenScraper,
195-
scraperV2: SourceTokenScraper
196-
): Promise<void> {
183+
async updateEndpoint(update: planner.EndpointUpdate, scraper: SourceTokenScraper): Promise<void> {
197184
update.endpoint.labels = { ...update.endpoint.labels, ...deploymentTool.labels() };
198185
if (update.deleteAndRecreate) {
199186
await this.deleteEndpoint(update.deleteAndRecreate);
200-
await this.createEndpoint(update.endpoint, scraperV1, scraperV2);
187+
await this.createEndpoint(update.endpoint, scraper);
201188
return;
202189
}
203190

204191
if (update.endpoint.platform === "gcfv1") {
205-
await this.updateV1Function(update.endpoint, scraperV1);
192+
await this.updateV1Function(update.endpoint, scraper);
206193
} else if (update.endpoint.platform === "gcfv2") {
207-
await this.updateV2Function(update.endpoint, scraperV2);
194+
await this.updateV2Function(update.endpoint, scraper);
208195
} else {
209196
assertExhaustive(update.endpoint.platform);
210197
}

src/test/deploy/functions/release/fabricator.spec.ts

Lines changed: 10 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1216,11 +1216,7 @@ describe("Fabricator", () => {
12161216
const createV1Function = sinon.stub(fab, "createV1Function");
12171217
createV1Function.resolves();
12181218

1219-
await fab.createEndpoint(
1220-
ep,
1221-
new scraper.SourceTokenScraper(),
1222-
new scraper.SourceTokenScraper()
1223-
);
1219+
await fab.createEndpoint(ep, new scraper.SourceTokenScraper());
12241220
expect(createV1Function).is.calledOnce;
12251221
expect(setTrigger).is.calledOnce;
12261222
expect(setTrigger).is.calledAfter(createV1Function);
@@ -1233,11 +1229,7 @@ describe("Fabricator", () => {
12331229
const createV2Function = sinon.stub(fab, "createV2Function");
12341230
createV2Function.resolves();
12351231

1236-
await fab.createEndpoint(
1237-
ep,
1238-
new scraper.SourceTokenScraper(),
1239-
new scraper.SourceTokenScraper()
1240-
);
1232+
await fab.createEndpoint(ep, new scraper.SourceTokenScraper());
12411233
expect(createV2Function).is.calledOnce;
12421234
expect(setTrigger).is.calledOnce;
12431235
expect(setTrigger).is.calledAfter(createV2Function);
@@ -1249,9 +1241,10 @@ describe("Fabricator", () => {
12491241
const createV1Function = sinon.stub(fab, "createV1Function");
12501242
createV1Function.rejects(new reporter.DeploymentError(ep, "set invoker", undefined));
12511243

1252-
await expect(
1253-
fab.createEndpoint(ep, new scraper.SourceTokenScraper(), new scraper.SourceTokenScraper())
1254-
).to.be.rejectedWith(reporter.DeploymentError, "set invoker");
1244+
await expect(fab.createEndpoint(ep, new scraper.SourceTokenScraper())).to.be.rejectedWith(
1245+
reporter.DeploymentError,
1246+
"set invoker"
1247+
);
12551248
expect(createV1Function).is.calledOnce;
12561249
expect(setTrigger).is.not.called;
12571250
});
@@ -1265,11 +1258,7 @@ describe("Fabricator", () => {
12651258
const updateV1Function = sinon.stub(fab, "updateV1Function");
12661259
updateV1Function.resolves();
12671260

1268-
await fab.updateEndpoint(
1269-
{ endpoint: ep },
1270-
new scraper.SourceTokenScraper(),
1271-
new scraper.SourceTokenScraper()
1272-
);
1261+
await fab.updateEndpoint({ endpoint: ep }, new scraper.SourceTokenScraper());
12731262
expect(updateV1Function).is.calledOnce;
12741263
expect(setTrigger).is.calledOnce;
12751264
expect(setTrigger).is.calledAfter(updateV1Function);
@@ -1282,11 +1271,7 @@ describe("Fabricator", () => {
12821271
const updateV2Function = sinon.stub(fab, "updateV2Function");
12831272
updateV2Function.resolves();
12841273

1285-
await fab.updateEndpoint(
1286-
{ endpoint: ep },
1287-
new scraper.SourceTokenScraper(),
1288-
new scraper.SourceTokenScraper()
1289-
);
1274+
await fab.updateEndpoint({ endpoint: ep }, new scraper.SourceTokenScraper());
12901275
expect(updateV2Function).is.calledOnce;
12911276
expect(setTrigger).is.calledOnce;
12921277
expect(setTrigger).is.calledAfter(updateV2Function);
@@ -1299,11 +1284,7 @@ describe("Fabricator", () => {
12991284
updateV1Function.rejects(new reporter.DeploymentError(ep, "set invoker", undefined));
13001285

13011286
await expect(
1302-
fab.updateEndpoint(
1303-
{ endpoint: ep },
1304-
new scraper.SourceTokenScraper(),
1305-
new scraper.SourceTokenScraper()
1306-
)
1287+
fab.updateEndpoint({ endpoint: ep }, new scraper.SourceTokenScraper())
13071288
).to.be.rejectedWith(reporter.DeploymentError, "set invoker");
13081289
expect(updateV1Function).is.calledOnce;
13091290
expect(setTrigger).is.not.called;
@@ -1332,11 +1313,7 @@ describe("Fabricator", () => {
13321313
const createV2Function = sinon.stub(fab, "createV2Function");
13331314
createV2Function.resolves();
13341315

1335-
await fab.updateEndpoint(
1336-
update,
1337-
new scraper.SourceTokenScraper(),
1338-
new scraper.SourceTokenScraper()
1339-
);
1316+
await fab.updateEndpoint(update, new scraper.SourceTokenScraper());
13401317

13411318
expect(deleteTrigger).to.have.been.called;
13421319
expect(deleteV1Function).to.have.been.calledImmediatelyAfter(deleteTrigger);

0 commit comments

Comments
 (0)