Skip to content

Commit

Permalink
fix(config): module variables weren't propagated right at parse time
Browse files Browse the repository at this point in the history
That's a facepalm...
  • Loading branch information
edvald committed Aug 6, 2021
1 parent 3764dfa commit b1c52fa
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
1 change: 1 addition & 0 deletions core/src/config/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ export function prepareModuleResource(spec: any, configPath: string, projectRoot
testConfigs: [],
type: spec.type,
taskConfigs: [],
variables: spec.variables,
}

validateWithPath({
Expand Down
10 changes: 6 additions & 4 deletions core/test/data/test-project-a/module-a/garden.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
kind: Module
name: module-a
type: test
variables:
msg: OK
services:
- name: service-a
build:
command: [echo, A]
tests:
- name: unit
command: [echo, OK]
command: [echo, "${var.msg}"]
- name: integration
command: [echo, OK]
dependencies:
command: [echo, "${var.msg}"]
dependencies:
- service-a
tasks:
- name: task-a
command: [echo, OK]
command: [echo, "${var.msg}"]
10 changes: 7 additions & 3 deletions core/test/unit/src/config/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ describe("loadConfigResources", () => {
allowPublish: undefined,
build: { dependencies: [] },
path: modulePathA,
variables: { msg: "OK" },

spec: {
build: {
Expand All @@ -142,17 +143,17 @@ describe("loadConfigResources", () => {
tasks: [
{
name: "task-a",
command: ["echo", "OK"],
command: ["echo", "${var.msg}"],
},
],
tests: [
{
name: "unit",
command: ["echo", "OK"],
command: ["echo", "${var.msg}"],
},
{
name: "integration",
command: ["echo", "OK"],
command: ["echo", "${var.msg}"],
dependencies: ["service-a"],
},
],
Expand Down Expand Up @@ -274,6 +275,7 @@ describe("loadConfigResources", () => {
},
testConfigs: [],
taskConfigs: [],
variables: undefined,
},
])
})
Expand Down Expand Up @@ -312,6 +314,7 @@ describe("loadConfigResources", () => {
},
testConfigs: [],
taskConfigs: [],
variables: undefined,
},
{
apiVersion: "garden.io/v0",
Expand Down Expand Up @@ -340,6 +343,7 @@ describe("loadConfigResources", () => {
},
testConfigs: [],
taskConfigs: [],
variables: undefined,
},
])
})
Expand Down
8 changes: 7 additions & 1 deletion examples/demo-project/backend/garden.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ kind: Module
name: backend
description: Backend service container
type: container

# You can specify variables here at the module level
variables:
ingressPath: /hello-backend

services:
- name: backend
ports:
Expand All @@ -10,8 +15,9 @@ services:
# Maps service:80 -> container:8080
servicePort: 80
ingresses:
- path: /hello-backend
- path: ${var.ingressPath}
port: http

tasks:
- name: test
command: ["sh", "-c", "echo task output"]

0 comments on commit b1c52fa

Please sign in to comment.