Skip to content

Commit

Permalink
improvement: set default include on Helm modules
Browse files Browse the repository at this point in the history
BREAKING CHANGE:

If not set by the user, the `include` field on Helm modules now defaults to:

```javascript
["*", "charts/**/*", "templates/**/*"]
```

if the module has local chart sources, otherwise to:

```javascript
["*", "charts/**/*", "templates/**/*"]
```

Previously, Helm modules would simply include all content under the
module path.

If your Helm modules doesn't have `include` set and depends
on content that's not captured with the default include, you will need
to update the relevant `garden.yml` file and set the includes manually.
  • Loading branch information
eysi09 authored and edvald committed Dec 17, 2019
1 parent c94b2ca commit fca600d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
5 changes: 5 additions & 0 deletions garden-service/src/plugins/kubernetes/helm/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,5 +352,10 @@ export async function configureHelmModule({
"release-name": getReleaseName(moduleConfig),
}

// Automatically set the include if not explicitly set
if (!moduleConfig.include) {
moduleConfig.include = containsSources ? ["*", "charts/**/*", "templates/**/*"] : []
}

return { moduleConfig }
}
15 changes: 14 additions & 1 deletion garden-service/test/integ/src/plugins/kubernetes/helm/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe("validateHelmModule", () => {
},
configPath: resolve(ctx.projectRoot, "api", "garden.yml"),
description: "The API backend for the voting UI",
include: undefined,
include: ["*", "charts/**/*", "templates/**/*"],
exclude: undefined,
name: "api",
outputs: {
Expand Down Expand Up @@ -122,6 +122,19 @@ describe("validateHelmModule", () => {
})
})

it("should not set default includes if they have already been explicitly set", async () => {
patchModuleConfig("api", { include: ["foo"] })
const config = await garden.resolveModuleConfig(garden.log, "api")
expect(config.include).to.eql(["foo"])
})

it("should set include to empty if module does not have local chart sources", async () => {
// So that Chart.yaml isn't found
patchModuleConfig("api", { spec: { chartPath: "invalid-path" } })
const config = await garden.resolveModuleConfig(garden.log, "api")
expect(config.include).to.eql([])
})

it("should not return a serviceConfig if skipDeploy=true", async () => {
patchModuleConfig("api", { spec: { skipDeploy: true } })
const config = await garden.resolveModuleConfig(garden.log, "api")
Expand Down

0 comments on commit fca600d

Please sign in to comment.