From 8ad24fd454520da1bfa16414386e828801116450 Mon Sep 17 00:00:00 2001 From: trujillo-adam Date: Tue, 28 Jan 2025 15:39:09 -0800 Subject: [PATCH] encoding functions --- .../functions/encoding/base64decode.mdx | 4 ++-- .../functions/encoding/base64encode.mdx | 4 ++-- .../functions/encoding/base64gzip.mdx | 5 ++--- .../functions/encoding/csvdecode.mdx | 4 ++-- .../functions/encoding/jsondecode.mdx | 6 +++--- .../functions/encoding/jsonencode.mdx | 4 ++-- .../functions/encoding/textdecodebase64.mdx | 4 ++-- .../functions/encoding/textencodebase64.mdx | 6 +++--- .../functions/encoding/urlencode.mdx | 4 ++-- .../functions/encoding/yamldecode.mdx | 6 +++--- .../functions/encoding/yamlencode.mdx | 4 ++-- .../hcl_templates/functions/index.mdx | 21 +++++++++---------- 12 files changed, 35 insertions(+), 37 deletions(-) diff --git a/website/content/docs/templates/hcl_templates/functions/encoding/base64decode.mdx b/website/content/docs/templates/hcl_templates/functions/encoding/base64decode.mdx index 8d9188230..7374373f2 100644 --- a/website/content/docs/templates/hcl_templates/functions/encoding/base64decode.mdx +++ b/website/content/docs/templates/hcl_templates/functions/encoding/base64decode.mdx @@ -1,6 +1,6 @@ --- -page_title: base64decode - Functions - Configuration Language -description: The base64decode function decodes a string containing a base64 sequence. +page_title: base64decode function reference +description: The `base64decode` function decodes a string containing a base64 sequence. Learn how to use the `base64decode` function in Packer templates. --- # `base64decode` Function diff --git a/website/content/docs/templates/hcl_templates/functions/encoding/base64encode.mdx b/website/content/docs/templates/hcl_templates/functions/encoding/base64encode.mdx index 2d3441d88..24788be4d 100644 --- a/website/content/docs/templates/hcl_templates/functions/encoding/base64encode.mdx +++ b/website/content/docs/templates/hcl_templates/functions/encoding/base64encode.mdx @@ -1,6 +1,6 @@ --- -page_title: base64encode - Functions - Configuration Language -description: The base64encode function applies Base64 encoding to a string. +page_title: base64encode function reference +description: The `base64encode` function applies base64 encoding to a string. Learn how to use the `base64encode` function in Packer templates. --- # `base64encode` Function diff --git a/website/content/docs/templates/hcl_templates/functions/encoding/base64gzip.mdx b/website/content/docs/templates/hcl_templates/functions/encoding/base64gzip.mdx index c015077df..95eed7272 100644 --- a/website/content/docs/templates/hcl_templates/functions/encoding/base64gzip.mdx +++ b/website/content/docs/templates/hcl_templates/functions/encoding/base64gzip.mdx @@ -1,7 +1,6 @@ --- -page_title: base64gzip - Functions - Configuration Language -description: The base64encode function compresses the given string with gzip and then - encodes the result in Base64. +page_title: base64gzip function reference +description: The `base64gzip` function compresses the given string using gzip and then encodes the result in base64. Learn how to use the `base64gzip` in Packer templates. --- # `base64gzip` Function diff --git a/website/content/docs/templates/hcl_templates/functions/encoding/csvdecode.mdx b/website/content/docs/templates/hcl_templates/functions/encoding/csvdecode.mdx index 88cb42d49..1c41c3fb6 100644 --- a/website/content/docs/templates/hcl_templates/functions/encoding/csvdecode.mdx +++ b/website/content/docs/templates/hcl_templates/functions/encoding/csvdecode.mdx @@ -1,6 +1,6 @@ --- -page_title: csvdecode - Functions - Configuration Language -description: The csvdecode function decodes CSV data into a list of maps. +page_title: csvdecode function reference +description: The `csvdecode` function decodes CSV data into a list of maps. Learn how to use the `csvdecode` function in Packer templates. --- # `csvdecode` Function diff --git a/website/content/docs/templates/hcl_templates/functions/encoding/jsondecode.mdx b/website/content/docs/templates/hcl_templates/functions/encoding/jsondecode.mdx index ade3fd2bd..96a68fa56 100644 --- a/website/content/docs/templates/hcl_templates/functions/encoding/jsondecode.mdx +++ b/website/content/docs/templates/hcl_templates/functions/encoding/jsondecode.mdx @@ -1,8 +1,8 @@ --- -page_title: jsondecode - Functions - Configuration Language +page_title: jsondecode function reference description: |- - The jsondecode function decodes a JSON string into a representation of its - value. + The `jsondecode` function decodes a JSON string into a representation of its + value. Learn how to use the `jsondecode` function in Packer templates. --- # `jsondecode` Function diff --git a/website/content/docs/templates/hcl_templates/functions/encoding/jsonencode.mdx b/website/content/docs/templates/hcl_templates/functions/encoding/jsonencode.mdx index fb75ee7fa..f9c92b89d 100644 --- a/website/content/docs/templates/hcl_templates/functions/encoding/jsonencode.mdx +++ b/website/content/docs/templates/hcl_templates/functions/encoding/jsonencode.mdx @@ -1,6 +1,6 @@ --- -page_title: jsonencode - Functions - Configuration Language -description: The jsonencode function encodes a given value as a JSON string. +page_title: jsonencode function reference +description: The `jsonencode` function encodes a given value as a JSON string. Learn how to use the `jsonencode` function in Packer templates. --- # `jsonencode` Function diff --git a/website/content/docs/templates/hcl_templates/functions/encoding/textdecodebase64.mdx b/website/content/docs/templates/hcl_templates/functions/encoding/textdecodebase64.mdx index 923d66bc8..fab4bd4f0 100644 --- a/website/content/docs/templates/hcl_templates/functions/encoding/textdecodebase64.mdx +++ b/website/content/docs/templates/hcl_templates/functions/encoding/textdecodebase64.mdx @@ -1,6 +1,6 @@ --- -page_title: testdecodebase64 - Functions - Configuration Language -description: The testdecodebase64 function converts a base64 encoded string, whose underlying encoding is the one specified as argument, into a UTF-8 string. +page_title: testdecodebase64 function reference +description: The `testdecodebase64` function converts a base64-encoded string into a UTF-8 string. Learn how to use the `testdecodebase64` function in Packer templates. --- # `textdecodebase64` Function diff --git a/website/content/docs/templates/hcl_templates/functions/encoding/textencodebase64.mdx b/website/content/docs/templates/hcl_templates/functions/encoding/textencodebase64.mdx index 6abff6371..a255719db 100644 --- a/website/content/docs/templates/hcl_templates/functions/encoding/textencodebase64.mdx +++ b/website/content/docs/templates/hcl_templates/functions/encoding/textencodebase64.mdx @@ -1,6 +1,6 @@ --- -page_title: testencodebase64 - Functions - Configuration Language -description: The testencodebase64 function converts a UTF-8 NFC input string to a base64 blob that encodes the target encoding's rendering of the input string. +page_title: testencodebase64 function reference +description: The `testencodebase64` function converts a UTF-8 NFC string into a base64 blob to match the destination encoding. Learn how to use the `testencodebase64` function in Packer templates. --- # `textencodebase64` Function @@ -8,7 +8,7 @@ description: The testencodebase64 function converts a UTF-8 NFC input string to Encodes the input string to the destination encoding. The output is base64-encoded to account for HCL's string encoding limitations: they must be UTF-8, NFC-normalised. -Packer uses the "standard" Base64 alphabet as defined in +Packer uses the standard base64 alphabet as defined in [RFC 4648 section 4](https://tools.ietf.org/html/rfc4648#section-4). The `encoding_name` argument must contain one of the encoding names or aliases recorded in diff --git a/website/content/docs/templates/hcl_templates/functions/encoding/urlencode.mdx b/website/content/docs/templates/hcl_templates/functions/encoding/urlencode.mdx index a2b8de5cc..40d3cdc97 100644 --- a/website/content/docs/templates/hcl_templates/functions/encoding/urlencode.mdx +++ b/website/content/docs/templates/hcl_templates/functions/encoding/urlencode.mdx @@ -1,6 +1,6 @@ --- -page_title: urlencode - Functions - Configuration Language -description: The urlencode function applies URL encoding to a given string. +page_title: urlencode function reference +description: The `urlencode` function applies URL encoding to a given string. Learn how to use the `urlencode` function in Packer templates. --- # `urlencode` Function diff --git a/website/content/docs/templates/hcl_templates/functions/encoding/yamldecode.mdx b/website/content/docs/templates/hcl_templates/functions/encoding/yamldecode.mdx index ea787ca2c..3157b039f 100644 --- a/website/content/docs/templates/hcl_templates/functions/encoding/yamldecode.mdx +++ b/website/content/docs/templates/hcl_templates/functions/encoding/yamldecode.mdx @@ -1,8 +1,8 @@ --- -page_title: yamldecode - Functions - Configuration Language +page_title: yamldecode function reference description: |- - The yamldecode function decodes a YAML string into a representation of its - value. + The `yamldecode` function decodes a YAML string into a representation of its + value. Learn how to use the `yamldecode` function in Packer templates. --- # `yamldecode` Function diff --git a/website/content/docs/templates/hcl_templates/functions/encoding/yamlencode.mdx b/website/content/docs/templates/hcl_templates/functions/encoding/yamlencode.mdx index 2aa017471..b37cad99c 100644 --- a/website/content/docs/templates/hcl_templates/functions/encoding/yamlencode.mdx +++ b/website/content/docs/templates/hcl_templates/functions/encoding/yamlencode.mdx @@ -1,6 +1,6 @@ --- -page_title: yamlencode - Functions - Configuration Language -description: The yamlencode function encodes a given value as a YAML string. +page_title: yamlencode function reference +description: The `yamlencode` function encodes a given value as a YAML string. Learn how to use the `yamlencode` function in Packer templates. --- # `yamlencode` Function diff --git a/website/content/docs/templates/hcl_templates/functions/index.mdx b/website/content/docs/templates/hcl_templates/functions/index.mdx index 0a9ee2a9e..3a504a1f9 100644 --- a/website/content/docs/templates/hcl_templates/functions/index.mdx +++ b/website/content/docs/templates/hcl_templates/functions/index.mdx @@ -1,16 +1,16 @@ --- -page_title: Functions - Configuration Language +page_title: Built-in functions reference overview description: |- - The HCL language has a number of built-in functions that can be called - from within expressions to transform and combine values. + Functions built into HCL language can transform and combine values. Learn about using built-in functions in your Packer templates. --- -# Built-in Functions +# Built-in functions overview -`@include 'from-1.5/beta-hcl2-note.mdx'` +This topic provides an overview of the built-in HashiCorp configuration language (HCL) functions you can use to create Packer templates. -The HCL language includes a number of built-in functions that you can -call from within expressions to transform and combine values. The general +## Functions syntax + +You can use functions in Packer templates to transform and combine values. The general syntax for function calls is a function name followed by comma-separated arguments in parentheses: @@ -19,8 +19,7 @@ max(5, 12, 9) ``` For information on invoking functions in string literals, refer to the -[String Literals](https://developer.hashicorp.com/packer/docs/templates/hcl_templates/expressions#string-literals) section -in the HCL2 expressions documentation. +[string literals reference](/packer/docs/templates/hcl_templates/expressions#string-literals) section. -The HCL language does not support user-defined functions, and so only -the functions built in to the language are available for use. The documentation includes all of the available built-in functions. +HCL does not support user-defined functions. You can only call +the functions built into the language.