Skip to content

Commit 83a33cb

Browse files
author
Andrew Farries
committed
Make client providers filter by app cluster
1 parent 7e550ef commit 83a33cb

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

Diff for: components/ws-manager-api/typescript/src/client-provider-source.ts

+7-6
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@ export interface WorkspaceManagerClientProviderSource {
1414
getAllWorkspaceClusters(): Promise<WorkspaceClusterWoTLS[]>;
1515
}
1616

17-
1817
@injectable()
1918
export class WorkspaceManagerClientProviderEnvSource implements WorkspaceManagerClientProviderSource {
2019
protected _clusters: WorkspaceCluster[] | undefined = undefined;
20+
readonly applicationCluster = process.env.GITPOD_INSTALLATION_SHORTNAME ?? "";
2121

2222
public async getWorkspaceCluster(name: string): Promise<WorkspaceCluster | undefined> {
23-
return this.clusters.find(m => m.name === name);
23+
return this.clusters.find((m) => m.name === name && m.applicationCluster === this.applicationCluster);
2424
}
2525

2626
public async getAllWorkspaceClusters(): Promise<WorkspaceClusterWoTLS[]> {
27-
return this.clusters;
27+
return this.clusters.filter((m) => m.applicationCluster === this.applicationCluster) ?? [];
2828
}
2929

3030
protected get clusters(): WorkspaceCluster[] {
@@ -63,13 +63,14 @@ export class WorkspaceManagerClientProviderEnvSource implements WorkspaceManager
6363
export class WorkspaceManagerClientProviderDBSource implements WorkspaceManagerClientProviderSource {
6464
@inject(WorkspaceClusterDB)
6565
protected readonly db: WorkspaceClusterDB;
66+
readonly applicationCluster = process.env.GITPOD_INSTALLATION_SHORTNAME ?? "";
6667

6768
public async getWorkspaceCluster(name: string): Promise<WorkspaceCluster | undefined> {
68-
return await this.db.findByName(name);
69+
return (await this.db.findFiltered({ name, applicationCluster: this.applicationCluster }))[0];
6970
}
7071

7172
public async getAllWorkspaceClusters(): Promise<WorkspaceClusterWoTLS[]> {
72-
return await this.db.findFiltered({});
73+
return await this.db.findFiltered({ applicationCluster: this.applicationCluster });
7374
}
7475
}
7576

@@ -105,4 +106,4 @@ export class WorkspaceManagerClientProviderCompositeSource implements WorkspaceM
105106
}
106107
return result;
107108
}
108-
}
109+
}

0 commit comments

Comments
 (0)