From fca600dd623046bcf0135b4535e7d5e525bca8e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ey=C3=BE=C3=B3r=20Magn=C3=BAsson?= Date: Tue, 17 Dec 2019 15:08:15 +0100 Subject: [PATCH] improvement: set default include on Helm modules 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. --- .../src/plugins/kubernetes/helm/config.ts | 5 +++++ .../integ/src/plugins/kubernetes/helm/config.ts | 15 ++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/garden-service/src/plugins/kubernetes/helm/config.ts b/garden-service/src/plugins/kubernetes/helm/config.ts index a73fd6df35..1a9f645df6 100644 --- a/garden-service/src/plugins/kubernetes/helm/config.ts +++ b/garden-service/src/plugins/kubernetes/helm/config.ts @@ -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 } } diff --git a/garden-service/test/integ/src/plugins/kubernetes/helm/config.ts b/garden-service/test/integ/src/plugins/kubernetes/helm/config.ts index 2ba1c0f0d0..c7a89c4205 100644 --- a/garden-service/test/integ/src/plugins/kubernetes/helm/config.ts +++ b/garden-service/test/integ/src/plugins/kubernetes/helm/config.ts @@ -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: { @@ -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")