Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

file inclusion improvement + docs #4768

Merged
merged 3 commits into from
Jul 7, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion core/src/graph/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,9 @@ export const actionFromConfig = profileAsync(async function actionFromConfig({
}
}

const configPath = relative(garden.projectRoot, config.internal.configFilePath || config.internal.basePath)

if (!actionTypes[config.kind][config.type]) {
const configPath = relative(garden.projectRoot, config.internal.configFilePath || config.internal.basePath)
const availableKinds: ActionKind[] = []
actionKinds.forEach((actionKind) => {
if (actionTypes[actionKind][config.type]) {
Expand Down Expand Up @@ -282,6 +283,18 @@ export const actionFromConfig = profileAsync(async function actionFromConfig({

const dependencies = dependenciesFromActionConfig(log, config, configsByKey, definition, templateContext)

if (config.exclude?.includes("**/*")) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we have equals here instead of includes, in case of something like src/test/**/*?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, can we also add a test for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

config.exclude is an array of strings. It's checking if the array includes the exact match of "**/*"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Writing tests was a good idea, found a bug in my original logic and removed some unwanted mutation
e4a9dce

if (config.include?.length !== 0) {
throw new ConfigurationError({
message: deline`Action ${config.kind}.${config.name} (defined at ${configPath})
tries to include files but excludes all files via "**/*".
Read about including and excluding files and directories here:
https://docs.garden.io/using-garden/configuration-overview#including-excluding-files-and-directories`,
})
}
config.include = []
}

const treeVersion =
config.internal.treeVersion ||
(await garden.vcs.getTreeVersion({ log, projectName: garden.projectName, config, scanRoot }))
Expand Down