Skip to content

Commit

Permalink
Merge pull request #9656 from hashicorp/docs-hcl2-tweaks-1.0.1
Browse files Browse the repository at this point in the history
Update HCL2 docs for 1.0.1
  • Loading branch information
Mahmood Ali authored Dec 16, 2020
2 parents 3812b6b + 5365ed3 commit 0f85a34
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 10 deletions.
51 changes: 50 additions & 1 deletion website/pages/docs/drivers/docker.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,56 @@ config {

- `work_dir` - (Optional) The working directory inside the container.

- `mounts` - (Optional) A list of
- `mount` - *Since 1.0.1* (Optional) Specify a
[mount](https://docs.docker.com/engine/reference/commandline/service_create/#add-bind-mounts-volumes-or-memory-filesystems)
to be mounted into the container. Volume, bind, and tmpfs type mounts are supported. May be specified multiple times.

```hcl
config {
# sample volume mount
mount {
type = "volume"
target = "/path/in/container"
source = "name-of-volume"
readonly = false
volume_options {
no_copy = false
labels {
foo = "bar"
}
driver_config {
name = "pxd"
options {
foo = "bar"
}
}
}
}
# sample bind mount
mount {
type = "bind"
target = "/path/in/container"
source = "/path/in/host"
readonly = false
bind_options {
propagation = "rshared"
}
}
# sample tmpfs mount
mount {
type = "tmpfs"
target = "/path/in/container"
readonly = false
tmpfs_options {
size = 100000 # size in bytes
}
}
}
```

- `mounts` - (*deprecated*: Replaced by `mount` in 1.0.1) (Optional) A list of
[mounts](https://docs.docker.com/engine/reference/commandline/service_create/#add-bind-mounts-volumes-or-memory-filesystems)
to be mounted into the container. Volume, bind, and tmpfs type mounts are supported.

Expand Down
11 changes: 11 additions & 0 deletions website/pages/docs/job-specification/hcl2/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,17 @@ mounts = [
]
```

Or better yet, the new [`mount`](/docs/driver/docker#mount) syntax, introduced in Nomad 1.0.1, is more appropriate here:

````hcl
mount {
type = "tmpfs"
tmpf_options {
size = 10000
}
}
```

### Multiline "here doc" string

Nomad supports multi-line string literals in the so-called "heredoc" style, inspired by Unix shell languages:
Expand Down
21 changes: 12 additions & 9 deletions website/pages/docs/job-specification/hcl2/variables.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,16 @@ documentation about the job, and so it should be written from the perspective
of the user of the job rather than its maintainer. For commentary for job
maintainers, use comments.

## Assigning Values to job Variables

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.

### Variables on the Command Line

To specify individual variables on the command line, use the `-var` option when
Expand All @@ -169,9 +179,6 @@ 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 @@ -224,8 +231,6 @@ Nomad matches the variable name exactly as given in configuration, and so the
required environment variable name will usually have a mix of upper and lower
case letters as in the above example.

--->

### Complex-typed Values

When variable values are provided in a variable definitions file, Nomad's
Expand Down Expand Up @@ -254,7 +259,6 @@ For readability, and to avoid the need to worry about shell escaping, we
recommend always setting complex variable values via variable definitions
files.

<!---
### Variable Definition Precedence

The above mechanisms for setting variables can be used together in any
Expand All @@ -264,7 +268,7 @@ Nomad loads variables in the following order, with later sources taking
precedence over earlier ones:

- Environment variables (lowest priority)
- Any `-var` options on the command line, in the order they are
- Any `-var` and `-var-file` 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 All @@ -274,8 +278,6 @@ that the same variable cannot be assigned multiple values within a single source
~> **Important:** Variables with map and object values behave the same way as
other variables: the last value found overrides the previous values.

--->

## A variable value must be known:

Take the following variable for example:
Expand All @@ -295,3 +297,4 @@ 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 |

0 comments on commit 0f85a34

Please sign in to comment.