diff --git a/docs/reference/template-strings.md b/docs/reference/template-strings.md index a4913873ed..aad31f9a21 100644 --- a/docs/reference/template-strings.md +++ b/docs/reference/template-strings.md @@ -37,7 +37,7 @@ lookups of keys. However, it is possible to do nested templating. For a somewhat ```yaml # ... env: - OTHER_MODULE_ENDPOINT: http://${variables.auth-module}/api/${modules.${variables.auth-module}.version} + OTHER_MODULE_ENDPOINT: http://${var.auth-module}/api/${modules.${var.auth-module}.version} ``` There the name of the module is pulled from the project/environment configuration, and used to find the diff --git a/docs/using-garden/configuration-files.md b/docs/using-garden/configuration-files.md index 33d477d3d6..aa66447b9f 100644 --- a/docs/using-garden/configuration-files.md +++ b/docs/using-garden/configuration-files.md @@ -44,7 +44,7 @@ provider instead of `local-kubernetes`. Here, project-wide configuration variables can also be specified (global, and/or environment-specific). These are then available for substitution in any string value in any module's `garden.yml`. -For example, assuming the above project configuration, `"foo-${variables.my-variable}-bar"` would evaluate to +For example, assuming the above project configuration, `"foo-${var.my-variable}-bar"` would evaluate to `"foo-hello-variable-bar"` when used as a string value in a module's `garden.yml`. ## Module Configuration diff --git a/examples/kubernetes-module/postgres/garden.yml b/examples/kubernetes-module/postgres/garden.yml index 6a6a2a658c..72b95d5883 100644 --- a/examples/kubernetes-module/postgres/garden.yml +++ b/examples/kubernetes-module/postgres/garden.yml @@ -15,7 +15,7 @@ manifests: heritage: "Tiller" type: Opaque data: - postgresql-password: ${variables.postgres-password} + postgresql-password: ${var.postgres-password} # Source: postgresql/templates/svc-headless.yaml - apiVersion: v1 kind: Service diff --git a/garden-service/src/config/config-context.ts b/garden-service/src/config/config-context.ts index 2f07885562..5a4f30a0e8 100644 --- a/garden-service/src/config/config-context.ts +++ b/garden-service/src/config/config-context.ts @@ -272,6 +272,12 @@ export class ModuleConfigContext extends ProjectConfigContext { ) public variables: PrimitiveMap + @schema( + joiIdentifierMap(joiPrimitive()) + .description("Alias for the variables field."), + ) + public var: PrimitiveMap + constructor( garden: Garden, environment: Environment, @@ -301,6 +307,6 @@ export class ModuleConfigContext extends ProjectConfigContext { this.providers = new Map(environment.providers.map(p => <[string, Provider]>[p.name, p])) - this.variables = environment.variables + this.var = this.variables = environment.variables } } diff --git a/garden-service/src/docs/templates/template-strings.hbs b/garden-service/src/docs/templates/template-strings.hbs index df71f03b74..925dc9b02c 100644 --- a/garden-service/src/docs/templates/template-strings.hbs +++ b/garden-service/src/docs/templates/template-strings.hbs @@ -37,7 +37,7 @@ lookups of keys. However, it is possible to do nested templating. For a somewhat ```yaml # ... env: - OTHER_MODULE_ENDPOINT: http://${variables.auth-module}/api/${modules.${variables.auth-module}.version} + OTHER_MODULE_ENDPOINT: http://${var.auth-module}/api/${modules.${var.auth-module}.version} ``` There the name of the module is pulled from the project/environment configuration, and used to find the diff --git a/garden-service/static/openfaas/system/openfaas-system/garden.yml b/garden-service/static/openfaas/system/openfaas-system/garden.yml index b4979fd47a..abdf254d95 100644 --- a/garden-service/static/openfaas/system/openfaas-system/garden.yml +++ b/garden-service/static/openfaas/system/openfaas-system/garden.yml @@ -5,18 +5,18 @@ module: repo: https://openfaas.github.io/faas-netes/ chart: openfaas version: 1.7.0 - releaseName: ${variables.release-name} + releaseName: ${var.release-name} values: exposeServices: false - functionNamespace: ${variables.function-namespace} + functionNamespace: ${var.function-namespace} ingress: enabled: true hosts: - - host: ${variables.gateway-hostname} + - host: ${var.gateway-hostname} serviceName: gateway servicePort: 8080 path: /function/ - - host: ${variables.gateway-hostname} + - host: ${var.gateway-hostname} serviceName: gateway servicePort: 8080 path: /system/ diff --git a/garden-service/test/unit/data/test-project-templated/module-a/garden.yml b/garden-service/test/unit/data/test-project-templated/module-a/garden.yml index 35cee2eef7..17ad53c6bc 100644 --- a/garden-service/test/unit/data/test-project-templated/module-a/garden.yml +++ b/garden-service/test/unit/data/test-project-templated/module-a/garden.yml @@ -5,7 +5,7 @@ module: - name: service-a command: [echo, "${local.env.TEST_VARIABLE}"] build: - command: [echo, "${variables.service-a-build-command}"] + command: [echo, "${var.service-a-build-command}"] tests: - name: unit command: [echo, OK] diff --git a/garden-service/test/unit/data/test-project-templated/module-b/garden.yml b/garden-service/test/unit/data/test-project-templated/module-b/garden.yml index 3c673f9df5..03d859a441 100644 --- a/garden-service/test/unit/data/test-project-templated/module-b/garden.yml +++ b/garden-service/test/unit/data/test-project-templated/module-b/garden.yml @@ -7,7 +7,7 @@ module: dependencies: - service-a build: - command: [echo, "${variables.service-a-build-command}"] + command: [echo, "${var.service-a-build-command}"] tests: - name: unit command: [echo, OK] diff --git a/garden-service/test/unit/data/test-project-variable-versioning/module-a/garden.yml b/garden-service/test/unit/data/test-project-variable-versioning/module-a/garden.yml index 21ad52cfa3..101ec2b5fb 100644 --- a/garden-service/test/unit/data/test-project-variable-versioning/module-a/garden.yml +++ b/garden-service/test/unit/data/test-project-variable-versioning/module-a/garden.yml @@ -2,7 +2,7 @@ module: name: module-a type: test build: - command: [echo, "${variables.echo-string}"] + command: [echo, "${var.echo-string}"] tests: - name: unit command: [echo, OK] diff --git a/garden-service/test/unit/src/config/config-context.ts b/garden-service/test/unit/src/config/config-context.ts index 5dd450f684..fcd1570c5c 100644 --- a/garden-service/test/unit/src/config/config-context.ts +++ b/garden-service/test/unit/src/config/config-context.ts @@ -274,4 +274,8 @@ describe("ModuleConfigContext", () => { it("should should resolve a project variable", async () => { expect(await c.resolve({ key: ["variables", "some"], nodePath: [], opts: {} })).to.equal("variable") }) + + it("should should resolve a project variable under the var alias", async () => { + expect(await c.resolve({ key: ["var", "some"], nodePath: [], opts: {} })).to.equal("variable") + }) })