-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Conor Evans <coevans@tcd.ie>
- Loading branch information
1 parent
f34e76a
commit 99b2155
Showing
3 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
website/content/docs/job-specification/hcl2/functions/file/filebase64.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
--- | ||
layout: docs | ||
page_title: filebase64 - Functions - Configuration Language | ||
description: |- | ||
The filebase64 function reads the contents of the file at the given path and | ||
returns them as a base64-encoded string. | ||
--- | ||
|
||
# `filebase64` Function | ||
|
||
`filebase64` reads the contents of a file at the given path and returns them as | ||
a base64-encoded string. | ||
|
||
```hcl | ||
filebase64(path) | ||
``` | ||
|
||
The result is a Base64 representation of the raw bytes in the given file. | ||
|
||
Nomad uses the "standard" Base64 alphabet as defined in | ||
[RFC 4648 section 4](https://tools.ietf.org/html/rfc4648#section-4). | ||
|
||
## Examples | ||
|
||
``` | ||
> filebase64("${path.module}/hello.txt") | ||
SGVsbG8gV29ybGQ= | ||
``` | ||
|
||
## Related Functions | ||
|
||
* [`file`](/docs/job-specification/hcl2/functions/file/file) also reads the contents of a given file, | ||
but interprets the data as UTF-8 text and returns the result directly | ||
as a string, without any further encoding. | ||
* [`base64decode`](/docs/job-specification/hcl2/functions/encoding/base64decode) can decode a | ||
Base64 string representing bytes in UTF-8, but in practice `base64decode(filebase64(...))` | ||
is equivalent to the shorter expression `file(...)`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters