diff --git a/core/src/config/base.ts b/core/src/config/base.ts index fdb44777334..3823ade92f7 100644 --- a/core/src/config/base.ts +++ b/core/src/config/base.ts @@ -348,6 +348,20 @@ function handleProjectModules(log: Log, projectSpec: ProjectConfig): ProjectConf log, "Project configuration field `modules` is deprecated in 0.13 and will be removed in 0.14. Please use the `scan` field instead." ) + const scanConfig = projectSpec.scan || {} + for (const key of ["include", "exclude"]) { + if (projectSpec["modules"][key]) { + if (!scanConfig[key]) { + scanConfig[key] = projectSpec["modules"][key] + } else { + log.warn( + `Project-level \`${key}\` is set both in \`modules.${key}\` and \`scan.${key}\`. The value from \`scan.${key}\` will be used (and the value from \`modules.${key}\` will not have any effect).` + ) + } + } + } + projectSpec.scan = scanConfig + delete projectSpec["modules"] } return projectSpec diff --git a/core/src/config/project.ts b/core/src/config/project.ts index 6a86db36eb8..06b7f215d61 100644 --- a/core/src/config/project.ts +++ b/core/src/config/project.ts @@ -31,7 +31,7 @@ import { memoize } from "lodash-es" import type { GenericProviderConfig } from "./provider.js" import { providerConfigBaseSchema } from "./provider.js" import type { GitScanMode } from "../constants.js" -import { DOCS_BASE_URL, GardenApiVersion, gitScanModes } from "../constants.js" +import { DOCS_BASE_URL, GardenApiVersion, defaultGitScanMode, gitScanModes } from "../constants.js" import { defaultDotIgnoreFile } from "../util/fs.js" import type { CommandInfo } from "../plugin-context.js" import type { VcsInfo } from "../vcs/vcs.js" @@ -267,7 +267,7 @@ const projectScanSchema = createSchema({ .string() .allow(...gitScanModes) .only() - .default("subtree") + .default(defaultGitScanMode) .description( "Choose how to perform scans of git repositories. The default (`subtree`) runs individual git scans on each action/module path. The `repo` mode scans entire repositories and then filters down to files matching the paths, includes and excludes for each action/module. This can be considerably more efficient for large projects with many actions/modules." ), @@ -424,7 +424,6 @@ export const projectSchema = createSchema({ "Key/value map of variables to configure for all environments. " + joiVariablesDescription ), }), - rename: [["modules", "scan"]], }) export function getDefaultEnvironmentName(defaultName: string, config: ProjectConfig): string { diff --git a/core/test/data/test-projects/project-include-exclude/garden.yml b/core/test/data/test-projects/project-include-exclude/garden.yml index fb2a1f7dbdc..8f7203b0fde 100644 --- a/core/test/data/test-projects/project-include-exclude/garden.yml +++ b/core/test/data/test-projects/project-include-exclude/garden.yml @@ -5,7 +5,12 @@ environments: - name: local providers: - name: test-plugin +# We use the old `modules.` fields to test the renaming/moving of the fields to +# `scan.` during project config preprocessing (see the `prepareProjectResource` helper). scan: + git: + mode: repo +modules: include: - module*/**/* exclude: