Skip to content

Commit

Permalink
fix: fixed bug in configuring flat-config modules
Browse files Browse the repository at this point in the history
This addresses an issue where config files defining Helm modules with
the flat config style would result in the Helm module not having its
path attribute set.
  • Loading branch information
thsig committed Feb 21, 2019
1 parent 9e71353 commit fd5bed8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
10 changes: 7 additions & 3 deletions garden-service/src/config/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ function prepareConfigDoc(spec: any, path: string, projectRoot: string): ConfigD

if (configKinds.has(kind)) {
const { specKey, validationSchema } = configKindSettings[kind]
delete spec.kind
const preparedSpec = prepareFlatConfigDoc(spec, path)
const validated = validateWithPath({
config: preparedSpec,
Expand All @@ -154,11 +153,15 @@ function prepareConfigDoc(spec: any, path: string, projectRoot: string): ConfigD
* The spec defines either a project or a module (determined by its "kind" field).
*/
function prepareFlatConfigDoc(spec: any, path: string): ConfigDoc {
if (spec.kind === "Project") {

const kind = spec.kind
delete spec.kind

if (kind === "Project") {
spec = prepareProjectConfig(spec, path)
}

if (spec.kind === "Module") {
if (kind === "Module") {
spec = prepareModuleConfig(spec, path)
}

Expand Down Expand Up @@ -222,6 +225,7 @@ function prepareProjectConfig(projectSpec: any, path: string): ProjectConfig {
}

function prepareModuleConfig(moduleSpec: any, path: string): ModuleConfig {

// Built-in keys are validated here and the rest are put into the `spec` field
const module = {
apiVersion: moduleSpec.apiVersion,
Expand Down
12 changes: 10 additions & 2 deletions garden-service/test/src/config/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ describe("loadConfig", () => {

expect(parsed!.project).to.eql({
apiVersion: "garden.io/v0",
defaultEnvironment: "",
defaultEnvironment: "local",
environmentDefaults: {
providers: [],
variables: { some: "variable" },
Expand All @@ -233,14 +233,22 @@ describe("loadConfig", () => {
})

expect(parsed!.modules).to.eql([{
apiVersion: "garden.io/v0",
name: "module-from-project-config",
type: "test",
description: undefined,
build: {
command: ["echo", "project"],
dependencies: [],
},
apiVersion: "garden.io/v0",
allowPublish: true,
outputs: {},
path: projectPathFlat,
repositoryUrl: undefined,
serviceConfigs: [],
spec: {},
taskConfigs: [],
testConfigs: [],
}])
})

Expand Down

0 comments on commit fd5bed8

Please sign in to comment.