Skip to content

Commit

Permalink
feat(commands): add fields to get config output
Browse files Browse the repository at this point in the history
Added `projectName` and `allEnvironmentNames` to the output of the `get
config` command.
  • Loading branch information
thsig authored and edvald committed Jun 24, 2020
1 parent 418506c commit 26334f6
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
6 changes: 5 additions & 1 deletion garden-service/src/garden.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1137,6 +1137,7 @@ export class Garden {

return {
environmentName: this.environmentName,
allEnvironmentNames: this.allEnvironmentNames,
namespace: this.namespace,
providers: Object.values(await this.resolveProviders()).map((p) => omit(p, ["tools"])),
variables: this.variables,
Expand All @@ -1145,6 +1146,7 @@ export class Garden {
"name"
),
workflowConfigs: sortBy(workflowConfigs, "name"),
projectName: this.projectName,
projectRoot: this.projectRoot,
projectId: this.projectId,
}
Expand All @@ -1154,12 +1156,14 @@ export class Garden {
}

export interface ConfigDump {
environmentName: string
environmentName: string // TODO: Remove this?
allEnvironmentNames: string[]
namespace?: string
providers: Omit<Provider, "tools">[]
variables: DeepPrimitiveMap
moduleConfigs: ModuleConfig[]
workflowConfigs: WorkflowConfig[]
projectName: string
projectRoot: string
projectId: string | null
}
23 changes: 23 additions & 0 deletions garden-service/test/unit/src/commands/get/get-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

import { expect } from "chai"
import { pick } from "lodash"
import { makeTestGardenA, withDefaultGlobalOpts } from "../../../../helpers"
import { GetConfigCommand } from "../../../../../src/commands/get/get-config"
import { sortBy } from "lodash"
Expand Down Expand Up @@ -34,6 +35,28 @@ describe("GetConfigCommand", () => {
expect(res.result?.moduleConfigs).to.deep.equal(expectedModuleConfigs)
})

it("should include the project name and all environment names", async () => {
const garden = await makeTestGardenA()
const log = garden.log
const command = new GetConfigCommand()

const result = (
await command.action({
garden,
log,
headerLog: log,
footerLog: log,
args: {},
opts: withDefaultGlobalOpts({ "exclude-disabled": false }),
})
).result

expect(pick(result, ["projectName", "allEnvironmentNames"])).to.eql({
projectName: "test-project-a",
allEnvironmentNames: ["local", "other"],
})
})

it("should include workflow configs", async () => {
const garden = await makeTestGardenA()
const log = garden.log
Expand Down

0 comments on commit 26334f6

Please sign in to comment.