From 3ce044876e83fdec7a42b643d50c8ff49eb6a227 Mon Sep 17 00:00:00 2001 From: Mahmood Ali Date: Thu, 10 Dec 2020 09:29:14 -0500 Subject: [PATCH 1/5] unquote env attributes --- website/pages/docs/job-specification/env.mdx | 2 -- website/pages/docs/runtime/interpolation.mdx | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/website/pages/docs/job-specification/env.mdx b/website/pages/docs/job-specification/env.mdx index bff811ed1..a2fad4bca 100644 --- a/website/pages/docs/job-specification/env.mdx +++ b/website/pages/docs/job-specification/env.mdx @@ -48,8 +48,6 @@ is preserved. env { key = 1.4 key = "1.4" - "key" = 1.4 - "key" = "1.4" key = true key = "1" diff --git a/website/pages/docs/runtime/interpolation.mdx b/website/pages/docs/runtime/interpolation.mdx index 0706d06ef..b3a873c55 100644 --- a/website/pages/docs/runtime/interpolation.mdx +++ b/website/pages/docs/runtime/interpolation.mdx @@ -47,8 +47,8 @@ task "docs" { # Environment variables are interpreted and can contain both runtime and # node attributes. These environment variables are passed into the task. env { - "DC" = "Running on datacenter ${node.datacenter}" - "VERSION" = "Version ${NOMAD_META_VERSION}" + DC = "Running on datacenter ${node.datacenter}" + VERSION = "Version ${NOMAD_META_VERSION}" } # Meta keys are also interpretable. From e7ace9f0045fd973efcc1a8839ec423163b4a1fc Mon Sep 17 00:00:00 2001 From: Mahmood Ali Date: Thu, 10 Dec 2020 11:33:13 -0500 Subject: [PATCH 2/5] docs: ensure meta keys are not quoted --- website/pages/docs/configuration/client.mdx | 6 +++--- website/pages/docs/job-specification/group.mdx | 2 +- website/pages/docs/job-specification/job.mdx | 2 +- website/pages/docs/job-specification/meta.mdx | 2 -- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/website/pages/docs/configuration/client.mdx b/website/pages/docs/configuration/client.mdx index d26f9c04f..aa5587ed7 100644 --- a/website/pages/docs/configuration/client.mdx +++ b/website/pages/docs/configuration/client.mdx @@ -459,9 +459,9 @@ client { node_class = "prod" meta { - "owner" = "ops" - "cached_binaries" = "redis,apache,nginx,jq,cypress,nodejs" - "rack" = "rack-12-1" + owner = "ops" + cached_binaries = "redis,apache,nginx,jq,cypress,nodejs" + rack = "rack-12-1" } } ``` diff --git a/website/pages/docs/job-specification/group.mdx b/website/pages/docs/job-specification/group.mdx index 23877db91..18561dba0 100644 --- a/website/pages/docs/job-specification/group.mdx +++ b/website/pages/docs/job-specification/group.mdx @@ -148,7 +148,7 @@ This example show arbitrary user-defined metadata on the group: ```hcl group "example" { meta { - "my-key" = "my-value" + my-key = "my-value" } } ``` diff --git a/website/pages/docs/job-specification/job.mdx b/website/pages/docs/job-specification/job.mdx index c12b83320..167e33159 100644 --- a/website/pages/docs/job-specification/job.mdx +++ b/website/pages/docs/job-specification/job.mdx @@ -30,7 +30,7 @@ job "docs" { } meta { - "my-key" = "my-value" + my-key = "my-value" } parameterized { diff --git a/website/pages/docs/job-specification/meta.mdx b/website/pages/docs/job-specification/meta.mdx index 8130191a7..73a24a42a 100644 --- a/website/pages/docs/job-specification/meta.mdx +++ b/website/pages/docs/job-specification/meta.mdx @@ -64,8 +64,6 @@ meta { key = "true" key = true - "key" = true - key = 1.4 key = "1.4" } From 4ad0a882ec5f3ced986a058b17e5199a23940b45 Mon Sep 17 00:00:00 2001 From: Mahmood Ali Date: Thu, 10 Dec 2020 09:33:21 -0500 Subject: [PATCH 3/5] docs: deactivate var-file section --var-files has a bug where we don't honor it properly. Let's remove it from docs, to be enabled for 1.0.1. --- website/pages/docs/job-specification/hcl2/variables.mdx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/website/pages/docs/job-specification/hcl2/variables.mdx b/website/pages/docs/job-specification/hcl2/variables.mdx index 92e12bf20..350d1df9c 100644 --- a/website/pages/docs/job-specification/hcl2/variables.mdx +++ b/website/pages/docs/job-specification/hcl2/variables.mdx @@ -158,7 +158,6 @@ maintainers, use comments. Once a variable is declared in your configuration, you can set it: - Individually, with the `-var foo=bar` command line option. -- In variable definitions files specified on the command line (with `-var-file=input.vars`). - As environment variables, for example: `NOMAD_VAR_foo=bar` The following sections describe these options in more detail. @@ -179,6 +178,9 @@ you at least set a default type instead of using empty blocks; this helps the HCL parser understand what is being set. Otherwise, the interpreter will assume that any variable set on the command line is a string. + ### Environment Variables @@ -268,7 +271,7 @@ Nomad loads variables in the following order, with later sources taking precedence over earlier ones: - Environment variables (lowest priority) -- Any `-var` and `-var-file` options on the command line, in the order they are +- Any `-var` options on the command line, in the order they are provided. (highest priority) If the same variable is assigned multiple values using different mechanisms, @@ -297,4 +300,3 @@ this behavior optional : | var.foo | error, "foo needs to be set" | null | xy | | `NOMAD_VAR_foo=yz`
var.foo | yz | yz | yz | | `-var foo=yz`
var.foo | yz | yz | yz | - From d4b153aded1d457da02b12f609401d85b1837b56 Mon Sep 17 00:00:00 2001 From: Mahmood Ali Date: Thu, 10 Dec 2020 11:26:09 -0500 Subject: [PATCH 4/5] note environment variables needing to be valid unicode identifier --- website/pages/docs/job-specification/hcl2/index.mdx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/website/pages/docs/job-specification/hcl2/index.mdx b/website/pages/docs/job-specification/hcl2/index.mdx index c2640ae0f..1a730b5fc 100644 --- a/website/pages/docs/job-specification/hcl2/index.mdx +++ b/website/pages/docs/job-specification/hcl2/index.mdx @@ -108,6 +108,13 @@ meta { } ``` +Additionally, block attributes must be [HCL2 valid identifiers](https://github.com/hashicorp/hcl/blob/v2.8.0/hclsyntax/spec.md#identifiers). +Loosely speaking, identifiers may only contain letters, numbers, underscore `_`, +or a dash `-`, and start with a letter. Notable, +[`meta`](https://www.nomadproject.io/docs/job-specification/meta), and +[`env`](https://www.nomadproject.io/docs/job-specification/env) keys may not +contain other symbols (e.g. `.`, `#`). + ### Multiline "here doc" strings Nomad supports multi-line string literals in the so-called "heredoc" style, inspired by Unix shell languages: From 64caae739361bf949cc3a20839181147ce7b5325 Mon Sep 17 00:00:00 2001 From: Mahmood Ali Date: Thu, 10 Dec 2020 12:21:01 -0500 Subject: [PATCH 5/5] Apply suggestions from code review Co-authored-by: Seth Hoenig --- website/pages/docs/job-specification/hcl2/index.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/pages/docs/job-specification/hcl2/index.mdx b/website/pages/docs/job-specification/hcl2/index.mdx index 1a730b5fc..2061427b5 100644 --- a/website/pages/docs/job-specification/hcl2/index.mdx +++ b/website/pages/docs/job-specification/hcl2/index.mdx @@ -109,7 +109,7 @@ meta { ``` Additionally, block attributes must be [HCL2 valid identifiers](https://github.com/hashicorp/hcl/blob/v2.8.0/hclsyntax/spec.md#identifiers). -Loosely speaking, identifiers may only contain letters, numbers, underscore `_`, +Generally, identifiers may only contain letters, numbers, underscore `_`, or a dash `-`, and start with a letter. Notable, [`meta`](https://www.nomadproject.io/docs/job-specification/meta), and [`env`](https://www.nomadproject.io/docs/job-specification/env) keys may not