diff --git a/core/src/config/base.ts b/core/src/config/base.ts index 597869e96a..e8ce3e41c1 100644 --- a/core/src/config/base.ts +++ b/core/src/config/base.ts @@ -84,6 +84,7 @@ export interface GardenResourceInternalFields { inputs?: DeepPrimitiveMap parentName?: string templateName?: string + templatePath?: string // Used to map fields to specific doc and location yamlDoc?: YamlDocumentWithSource } diff --git a/core/src/config/module.ts b/core/src/config/module.ts index 1d3a69e1e0..bf93a73d5e 100644 --- a/core/src/config/module.ts +++ b/core/src/config/module.ts @@ -297,6 +297,7 @@ export interface ModuleConfig { { type: "test", name: "${parent.name}-${template.name}-${inputs.foo}", + variables: { templatePath: "${template.path}" }, build: { dependencies: [{ name: "${parent.name}-${template.name}-foo", copy: [] }], timeout: DEFAULT_BUILD_TIMEOUT_SEC, @@ -205,6 +206,7 @@ describe("config templates", () => { expect(module.name).to.equal("test-test-bar") expect(module.build.dependencies).to.eql([{ name: "test-test-foo", copy: [] }]) expect(module.spec.image).to.equal("${modules.foo.outputs.bar || inputs.foo}") + expect(module.variables!["templatePath"]).to.equal(garden.projectRoot) }) it("throws if config is invalid", async () => { diff --git a/core/test/unit/src/config/template-contexts/module.ts b/core/test/unit/src/config/template-contexts/module.ts index 631047293c..9ce5b2d495 100644 --- a/core/test/unit/src/config/template-contexts/module.ts +++ b/core/test/unit/src/config/template-contexts/module.ts @@ -49,6 +49,7 @@ describe("ModuleConfigContext", () => { parentName: module.parentName, inputs: module.inputs, templateName: module.templateName, + templatePath: module.templatePath, }) })