Skip to content

Commit

Permalink
fix(cli): bad error message when --env namespace is set on some commands
Browse files Browse the repository at this point in the history
Fixes #2093
  • Loading branch information
edvald authored and thsig committed Oct 6, 2020
1 parent 7249ab6 commit cd41a1f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 2 additions & 2 deletions core/src/cli/cli.ts
Expand Up @@ -29,7 +29,7 @@ import {
parseCliArgs,
} from "./helpers"
import { Parameters, globalOptions, OUTPUT_RENDERERS, GlobalOptions, ParameterValues } from "./params"
import { defaultEnvironments, ProjectConfig, defaultNamespace } from "../config/project"
import { defaultEnvironments, ProjectConfig, defaultNamespace, parseEnvironment } from "../config/project"
import { ERROR_LOG_FILENAME, DEFAULT_API_VERSION, DEFAULT_GARDEN_DIR_NAME, LOGS_DIR_NAME } from "../constants"
import { generateBasicDebugInfoReport } from "../commands/get/get-debug-info"
import { AnalyticsHandler } from "../analytics/analytics"
Expand All @@ -43,7 +43,7 @@ import { GardenPlugin } from "../types/plugin/plugin"

export async function makeDummyGarden(root: string, gardenOpts: GardenOpts = {}) {
const environments = gardenOpts.environmentName
? [{ name: gardenOpts.environmentName, defaultNamespace, variables: {} }]
? [{ name: parseEnvironment(gardenOpts.environmentName).environment, defaultNamespace, variables: {} }]
: defaultEnvironments

const config: ProjectConfig = {
Expand Down
10 changes: 9 additions & 1 deletion core/test/unit/src/cli/cli.ts
Expand Up @@ -918,13 +918,21 @@ describe("cli", () => {
expect(garden).to.be.ok
expect(dg.getModules()).to.not.throw
})

it("should correctly configure a dummy environment when a namespace is set", async () => {
const garden = await makeDummyGarden(join(GARDEN_CORE_ROOT, "tmp", "foobarbas"), { environmentName: "test.foo" })
expect(garden).to.be.ok
expect(garden.environmentName).to.equal("foo")
})

it("should initialise and resolve config graph in a project with invalid config", async () => {
const root = getDataDir("test-project-invalid-config")
const garden = await makeDummyGarden(root, {})
const dg = await garden.getConfigGraph(garden.log)
expect(garden).to.be.ok
expect(await dg.getModules()).to.not.throw
expect(dg.getModules()).to.not.throw
})

it("should initialise and resolve config graph in a project with template strings", async () => {
const root = getDataDir("test-project-templated")
const garden = await makeDummyGarden(root, {})
Expand Down

0 comments on commit cd41a1f

Please sign in to comment.