From 3fd520e9519a7a07ff30d3f43b41da1d475445cd Mon Sep 17 00:00:00 2001 From: Jon Edvald Date: Sat, 14 Dec 2019 15:55:30 +0100 Subject: [PATCH] fix(config): detect overlap after resolving module configs Without this, the automatic includes/excludes that providers set will have no effect. --- garden-service/src/garden.ts | 14 +++++++------- garden-service/test/unit/src/garden.ts | 7 +++++++ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/garden-service/src/garden.ts b/garden-service/src/garden.ts index 91a7bb4f22..8ea5f6dcf4 100644 --- a/garden-service/src/garden.ts +++ b/garden-service/src/garden.ts @@ -601,6 +601,13 @@ export class Garden { let graph: ConfigGraph | undefined = undefined + // Require include/exclude on modules if their paths overlap + const overlaps = detectModuleOverlap(moduleConfigs) + if (overlaps.length > 0) { + const { message, detail } = this.makeOverlapError(overlaps) + throw new ConfigurationError(message, detail) + } + // Walk through all plugins in dependency order, and allow them to augment the graph for (const provider of getDependencyOrder(providers, this.registeredPlugins)) { // Skip the routine if the provider doesn't have the handler @@ -792,13 +799,6 @@ export class Garden { } }) - // Require include/exclude on modules if their paths overlap - const overlaps = detectModuleOverlap(rawConfigs) - if (overlaps.length > 0) { - const { message, detail } = this.makeOverlapError(overlaps) - throw new ConfigurationError(message, detail) - } - await Bluebird.map(rawConfigs, async (config) => this.addModule(config)) this.log.silly(`Scanned and found ${rawConfigs.length} modules`) diff --git a/garden-service/test/unit/src/garden.ts b/garden-service/test/unit/src/garden.ts index e44d0efa79..2a9c560a8d 100644 --- a/garden-service/test/unit/src/garden.ts +++ b/garden-service/test/unit/src/garden.ts @@ -2625,6 +2625,7 @@ describe("Garden", () => { build: { dependencies: [] }, outputs: {}, path: "/tmp", + include: [], serviceConfigs: [], taskConfigs: [], testConfigs: [], @@ -2638,6 +2639,7 @@ describe("Garden", () => { build: { dependencies: [] }, outputs: {}, path: "/tmp", + include: [], serviceConfigs: [], taskConfigs: [], testConfigs: [], @@ -2656,6 +2658,7 @@ describe("Garden", () => { name: "foo", outputs: {}, path: "/tmp", + include: [], serviceConfigs: [], spec: { build: { dependencies: [] } }, testConfigs: [], @@ -2674,6 +2677,7 @@ describe("Garden", () => { schema: joi.object().keys({ foo: joi.string(), build: baseBuildSpecSchema }), handlers: { configure: async ({ moduleConfig }) => { + moduleConfig.include = [] moduleConfig.serviceConfigs = [ { name: moduleConfig.name, @@ -2728,6 +2732,7 @@ describe("Garden", () => { outputs: {}, configPath: "/tmp", path: "/tmp", + include: [], serviceConfigs: [ { name: "foo", @@ -2795,6 +2800,7 @@ describe("Garden", () => { schema: joi.object().keys({ foo: joi.string(), build: baseBuildSpecSchema }), handlers: { configure: async ({ moduleConfig }) => { + moduleConfig.include = [] moduleConfig.serviceConfigs = [ { name: moduleConfig.name, @@ -2859,6 +2865,7 @@ describe("Garden", () => { name: "foo", outputs: {}, path: "/tmp", + include: [], serviceConfigs: [ { name: "foo",