Skip to content

Commit

Permalink
fix(config): detect overlap after resolving module configs
Browse files Browse the repository at this point in the history
Without this, the automatic includes/excludes that providers set will
have no effect.
  • Loading branch information
edvald committed Dec 14, 2019
1 parent 7551646 commit 3fd520e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
14 changes: 7 additions & 7 deletions garden-service/src/garden.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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`)
Expand Down
7 changes: 7 additions & 0 deletions garden-service/test/unit/src/garden.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2625,6 +2625,7 @@ describe("Garden", () => {
build: { dependencies: [] },
outputs: {},
path: "/tmp",
include: [],
serviceConfigs: [],
taskConfigs: [],
testConfigs: [],
Expand All @@ -2638,6 +2639,7 @@ describe("Garden", () => {
build: { dependencies: [] },
outputs: {},
path: "/tmp",
include: [],
serviceConfigs: [],
taskConfigs: [],
testConfigs: [],
Expand All @@ -2656,6 +2658,7 @@ describe("Garden", () => {
name: "foo",
outputs: {},
path: "/tmp",
include: [],
serviceConfigs: [],
spec: { build: { dependencies: [] } },
testConfigs: [],
Expand All @@ -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,
Expand Down Expand Up @@ -2728,6 +2732,7 @@ describe("Garden", () => {
outputs: {},
configPath: "/tmp",
path: "/tmp",
include: [],
serviceConfigs: [
{
name: "foo",
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -2859,6 +2865,7 @@ describe("Garden", () => {
name: "foo",
outputs: {},
path: "/tmp",
include: [],
serviceConfigs: [
{
name: "foo",
Expand Down

0 comments on commit 3fd520e

Please sign in to comment.