From c587de9e04bb0f4c792049b8047f348e8a307829 Mon Sep 17 00:00:00 2001 From: Thorarinn Sigurdsson Date: Thu, 30 Jul 2020 11:47:17 +0000 Subject: [PATCH] fix(enterprise): add project id to config dump This fixes a recent regression where project IDs would not be included in the output of the `get config` command unless logged in. --- garden-service/src/garden.ts | 8 ++++++-- garden-service/test/unit/src/commands/get/get-config.ts | 5 +++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/garden-service/src/garden.ts b/garden-service/src/garden.ts index 8824b57b37..2aca27759f 100644 --- a/garden-service/src/garden.ts +++ b/garden-service/src/garden.ts @@ -124,6 +124,7 @@ export interface GardenEnterpriseContext { export interface GardenParams { artifactsPath: string buildDir: BuildDir + projectId: string | null enterpriseContext: GardenEnterpriseContext | null dotIgnoreFiles: string[] environmentName: string @@ -163,7 +164,8 @@ export class Garden { private readonly taskGraph: TaskGraph private watcher: Watcher private asyncLock: any - public enterpriseContext: GardenEnterpriseContext | null + public readonly enterpriseContext: GardenEnterpriseContext | null + public readonly projectId: string | null public sessionId: string | null public readonly configStore: ConfigStore public readonly globalConfigStore: GlobalConfigStore @@ -200,6 +202,7 @@ export class Garden { constructor(params: GardenParams) { this.buildDir = params.buildDir this.enterpriseContext = params.enterpriseContext + this.projectId = params.projectId this.sessionId = params.sessionId this.environmentName = params.environmentName this.environmentConfigs = params.environmentConfigs @@ -339,6 +342,7 @@ export class Garden { const garden = new this({ artifactsPath, sessionId, + projectId: projectId || null, enterpriseContext, projectRoot, projectName, @@ -1178,7 +1182,7 @@ export class Garden { workflowConfigs: sortBy(workflowConfigs, "name"), projectName: this.projectName, projectRoot: this.projectRoot, - projectId: this.enterpriseContext ? this.enterpriseContext.projectId : undefined, + projectId: this.projectId || undefined, } } diff --git a/garden-service/test/unit/src/commands/get/get-config.ts b/garden-service/test/unit/src/commands/get/get-config.ts index ddd20ba0ff..44052286da 100644 --- a/garden-service/test/unit/src/commands/get/get-config.ts +++ b/garden-service/test/unit/src/commands/get/get-config.ts @@ -37,7 +37,7 @@ describe("GetConfigCommand", () => { expect(res.result?.moduleConfigs).to.deep.equal(expectedModuleConfigs) }) - it("should include the project name and all environment names", async () => { + it("should include the project name, id and all environment names", async () => { const garden = await makeTestGardenA() const log = garden.log const command = new GetConfigCommand() @@ -53,8 +53,9 @@ describe("GetConfigCommand", () => { }) ).result - expect(pick(result, ["projectName", "allEnvironmentNames"])).to.eql({ + expect(pick(result, ["projectName", "projectId", "allEnvironmentNames"])).to.eql({ projectName: "test-project-a", + projectId: "test-project-id", allEnvironmentNames: ["local", "other"], }) })