diff --git a/core/src/config/base.ts b/core/src/config/base.ts index fdb4477733..3823ade92f 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 6a86db36eb..06b7f215d6 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 fb2a1f7dbd..8f7203b0fd 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: diff --git a/docs/reference/project-config.md b/docs/reference/project-config.md index 6a337f0320..2abffa2557 100644 --- a/docs/reference/project-config.md +++ b/docs/reference/project-config.md @@ -159,7 +159,7 @@ scan: # 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. - mode: subtree + mode: repo # A list of output values that the project should export. These are exported by the `garden get outputs` command, as # well as when referencing a project as a sub-project within another project. @@ -578,9 +578,9 @@ scan: 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. -| Type | Allowed Values | Default | Required | -| -------- | ----------------- | ----------- | -------- | -| `string` | "repo", "subtree" | `"subtree"` | Yes | +| Type | Allowed Values | Default | Required | +| -------- | ----------------- | -------- | -------- | +| `string` | "repo", "subtree" | `"repo"` | Yes | ### `outputs[]`