Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Moe unquoting of HCL block attributes #9612

Merged
merged 5 commits into from
Dec 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions website/pages/docs/configuration/client.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
```
Expand Down
2 changes: 0 additions & 2 deletions website/pages/docs/job-specification/env.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ is preserved.
env {
key = 1.4
key = "1.4"
"key" = 1.4
"key" = "1.4"

key = true
key = "1"
Expand Down
2 changes: 1 addition & 1 deletion website/pages/docs/job-specification/group.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
```
Expand Down
7 changes: 7 additions & 0 deletions website/pages/docs/job-specification/hcl2/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Generally, identifiers may only contain letters, numbers, underscore `_`,
or a dash `-`, and start with a letter. Notable,
notnoop marked this conversation as resolved.
Show resolved Hide resolved
[`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:
Expand Down
8 changes: 5 additions & 3 deletions website/pages/docs/job-specification/hcl2/variables.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.

<!---
# TODO (hcl2): Renable for 1.0.1 by reverting the comment out commit

### Variable Definitions Files

To set lots of variables, it is more convenient to specify their values in a
Expand Down Expand Up @@ -209,6 +211,7 @@ corresponding to variable names:
"labels": ["testing", "internal"],
}
```
--->

### Environment Variables

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -297,4 +300,3 @@ this behavior optional :
| var.foo | error, "foo needs to be set" | null | xy |
| `NOMAD_VAR_foo=yz`<br />var.foo | yz | yz | yz |
| `-var foo=yz`<br />var.foo | yz | yz | yz |

2 changes: 1 addition & 1 deletion website/pages/docs/job-specification/job.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ job "docs" {
}

meta {
"my-key" = "my-value"
my-key = "my-value"
}

parameterized {
Expand Down
2 changes: 0 additions & 2 deletions website/pages/docs/job-specification/meta.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ meta {
key = "true"
key = true

"key" = true

key = 1.4
key = "1.4"
}
Expand Down
4 changes: 2 additions & 2 deletions website/pages/docs/runtime/interpolation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down