chore(docs): update file HCL function (#18696)

This commit is contained in:
Kevin Wang
2023-10-16 04:03:50 -04:00
committed by GitHub
parent 299f3bf74b
commit 6dcc402188

View File

@@ -9,7 +9,7 @@ description: |-
# `file` Function
`file` reads the contents of a file at the given path and returns them as
a string.
a string. Relative paths will be resolved based on the CLIs current working directory.
```hcl
file(path)
@@ -30,6 +30,31 @@ so this function can only be used with files that are already present on disk on
Hello World
```
Or in an example job specification:
```hcl
# /path/to/example/jobspec.nomad
job "test" {
group "test" {
task "test" {
driver = "docker"
config {
image = "test/image:latest"
volumes = [
"local/file.txt:/path/to/file/on/container/file.txt"
]
}
template {
data = file("/path/to/example/file.txt")
destination = "local/file.txt"
}
}
}
}
```
## Related Functions
- [`fileexists`](/nomad/docs/job-specification/hcl2/functions/file/fileexists) determines whether a file exists