Skip to content

Commit 794d0aa

Browse files
committed
Update priority (prioritize User level vars)
1 parent 6bda4f6 commit 794d0aa

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ describe("EnvVarService", async () => {
311311
const workspaceConfig: WorkspaceConfig = {
312312
env: {
313313
foobar: "yes please",
314-
[fooAnyUserEnvVar.name]: "overridden",
314+
[fooAnyUserEnvVar.name]: "overridden_by_user_var",
315315
},
316316
};
317317

@@ -336,7 +336,7 @@ describe("EnvVarService", async () => {
336336
})),
337337
);
338338
expect(envVars.workspace).to.have.deep.members([
339-
{ name: fooAnyUserEnvVar.name, value: "overridden" },
339+
fooAnyUserEnvVar,
340340
barUserCommitEnvVar,
341341
bazProjectEnvVar,
342342
{ name: "foobar", value: "yes please" },

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -260,14 +260,7 @@ export class EnvVarService {
260260
};
261261
}
262262

263-
// 1. first merge user envs
264-
if (CommitContext.is(wsContext)) {
265-
// this is a commit context, thus we can filter the env vars
266-
const userEnvVars = await this.userDB.getEnvVars(requestorId);
267-
merge(UserEnvVar.filter(userEnvVars, wsContext.repository.owner, wsContext.repository.name));
268-
}
269-
270-
// 2. then from the .gitpod.yml
263+
// 1. first merge the `env` in the .gitpod.yml
271264
if (wsConfig?.env) {
272265
const configEnvVars = Object.entries(wsConfig.env as Record<string, string>).map(([name, value]) => ({
273266
name,
@@ -276,6 +269,13 @@ export class EnvVarService {
276269
merge(configEnvVars);
277270
}
278271

272+
// 2. then user envs
273+
if (CommitContext.is(wsContext)) {
274+
// this is a commit context, thus we can filter the env vars
275+
const userEnvVars = await this.userDB.getEnvVars(requestorId);
276+
merge(UserEnvVar.filter(userEnvVars, wsContext.repository.owner, wsContext.repository.name));
277+
}
278+
279279
// 3. then from the project
280280
if (projectEnvVars.length) {
281281
// Instead of using an access guard for Project environment variables, we let Project owners decide whether

0 commit comments

Comments
 (0)