Skip to content

Commit 7194522

Browse files
committed
Introduce listOrgEnvVarsWithValues
Tool: gitpod/catfood.gitpod.cloud
1 parent 2cbdd47 commit 7194522

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

components/server/src/user/env-var-service.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,13 @@ export class EnvVarService {
234234
return this.orgDB.getOrgEnvironmentVariables(orgId);
235235
}
236236

237+
async listOrgEnvVarsWithValues(requestorId: string, orgId: string): Promise<OrgEnvVarWithValue[]> {
238+
const envVars = (await ApplicationError.notFoundToUndefined(this.listOrgEnvVars(requestorId, orgId))) ?? [];
239+
const envVarValues = await this.orgDB.getOrgEnvironmentVariableValues(envVars);
240+
241+
return envVarValues;
242+
}
243+
237244
async getOrgEnvVarById(requestorId: string, id: string): Promise<OrgEnvVar> {
238245
const result = await this.orgDB.getOrgEnvironmentVariableById(id);
239246
if (!result) {

components/server/src/workspace/workspace-starter.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ import {
4242
ImageBuildLogInfo,
4343
ImageConfigFile,
4444
NamedWorkspaceFeatureFlag,
45-
OrgEnvVarWithValue,
4645
Permission,
4746
Project,
4847
RefType,
@@ -129,7 +128,7 @@ import { TokenProvider } from "../user/token-provider";
129128
import { UserAuthentication } from "../user/user-authentication";
130129
import { ImageSourceProvider } from "./image-source-provider";
131130
import { WorkspaceClassesConfig } from "./workspace-classes";
132-
import { SYSTEM_USER, SYSTEM_USER_ID, Authorizer } from "../authorization/authorizer";
131+
import { SYSTEM_USER, SYSTEM_USER_ID } from "../authorization/authorizer";
133132
import { EnvVarService, ResolvedEnvVars } from "../user/env-var-service";
134133
import { RedlockAbortSignal } from "redlock";
135134
import { ConfigProvider } from "./config-provider";
@@ -240,7 +239,6 @@ export class WorkspaceStarter {
240239
@inject(EnvVarService) private readonly envVarService: EnvVarService,
241240
@inject(OrganizationService) private readonly orgService: OrganizationService,
242241
@inject(ProjectsService) private readonly projectService: ProjectsService,
243-
@inject(Authorizer) private readonly auth: Authorizer,
244242
) {}
245243

246244
public async startWorkspace(
@@ -2047,11 +2045,9 @@ export class WorkspaceStarter {
20472045

20482046
// if the image resolution is for an organization, we also include the organization's set up env vars
20492047
if (organizationId) {
2050-
await this.auth.checkPermissionOnOrganization(user.id, "read_env_var", organizationId);
2051-
const orgEnvVars = await this.orgDB.getOrgEnvironmentVariables(organizationId);
2052-
const orgEnvVarValues: OrgEnvVarWithValue[] = await this.orgDB.getOrgEnvironmentVariableValues(orgEnvVars);
2048+
const envVars = await this.envVarService.listOrgEnvVarsWithValues(user.id, organizationId);
20532049

2054-
const additionalAuth = await this.getAdditionalImageAuth({ workspace: orgEnvVarValues });
2050+
const additionalAuth = await this.getAdditionalImageAuth({ workspace: envVars });
20552051
additionalAuth.forEach((val, key) => auth.getAdditionalMap().set(key, val));
20562052
}
20572053

0 commit comments

Comments
 (0)