Skip to content

Commit c4bc771

Browse files
committed
Remove --location from apphosting:backends:get and return the first backend if multiple are found.
1 parent 618cfb4 commit c4bc771

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

src/commands/apphosting-backends-get.ts

+11-14
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,15 @@ import { printBackendsTable } from "./apphosting-backends-list";
88

99
export const command = new Command("apphosting:backends:get <backend>")
1010
.description("print info about a Firebase App Hosting backend")
11-
.option("-l, --location <location>", "backend location")
1211
.before(apphosting.ensureApiEnabled)
1312
.action(async (backend: string, options: Options) => {
1413
const projectId = needProjectId(options);
15-
if (options.location !== undefined) {
16-
logWarning("--location is being removed in the next major release.");
17-
}
18-
const location = (options.location as string) ?? "-";
1914

2015
let backendsList: apphosting.Backend[] = [];
2116
try {
22-
if (location !== "-") {
23-
const backendInRegion = await apphosting.getBackend(projectId, location, backend);
24-
backendsList.push(backendInRegion);
25-
} else {
26-
const resp = await apphosting.listBackends(projectId, "-");
27-
const allBackends = resp.backends || [];
28-
backendsList = allBackends.filter((bkd) => bkd.name.split("/").pop() === backend);
29-
}
17+
const resp = await apphosting.listBackends(projectId, "-");
18+
const allBackends = resp.backends || [];
19+
backendsList = allBackends.filter((bkd) => bkd.name.split("/").pop() === backend);
3020
} catch (err: unknown) {
3121
throw new FirebaseError(
3222
`Failed to get backend: ${backend}. Please check the parameters you have provided.`,
@@ -37,6 +27,13 @@ export const command = new Command("apphosting:backends:get <backend>")
3727
logWarning(`Backend "${backend}" not found`);
3828
return;
3929
}
40-
printBackendsTable(backendsList);
30+
if (backendsList.length > 1) {
31+
logWarning(
32+
`Detected multiple backends with the same ${backend} ID. This is not allowed until we can support more locations.\n` +
33+
`Please delete and recreate any backends that share an ID with another backend. ` +
34+
`Use apphosting:backends:list to see all backends.\n Returning the following backend:`,
35+
);
36+
}
37+
printBackendsTable(backendsList.slice(0, 1));
4138
return backendsList[0];
4239
});

0 commit comments

Comments
 (0)