From 38c50cf00eea0e674e03404aa0b98a8d98d38ea6 Mon Sep 17 00:00:00 2001 From: Adrien Delorme Date: Fri, 13 Nov 2020 11:05:57 +0100 Subject: [PATCH] HCL2: Add more documentation to path-variables (#10245) * HCL2: Add more documentation to path-variables Co-authored-by: Wilken Rivera --- .../pages/docs/from-1.5/path-variables.mdx | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/website/pages/docs/from-1.5/path-variables.mdx b/website/pages/docs/from-1.5/path-variables.mdx index 619b7526b..d95e468de 100644 --- a/website/pages/docs/from-1.5/path-variables.mdx +++ b/website/pages/docs/from-1.5/path-variables.mdx @@ -12,3 +12,30 @@ description: |- - `path.cwd`: the directory from where Packer was started. - `path.root`: the directory of the input HCL file or the input folder. + + +## Examples + +```HCL +locals { + settings_file = "${path.cwd}/settings.txt" + scripts_folder = "${path.root}/scripts" + root = path.root +} +``` + +## Related Functions + +- [`abspath`](/docs/from-1.5/functions/file/abspath) takes a string containing + a filesystem path and converts it to an absolute path. + +- [`basename`](/docs/from-1.5/functions/file/basename) returns _only_ the last + portion of a filesystem path, discarding the portion that would be returned + by `dirname`. + +- [`fileset`](/docs/from-1.5/functions/file/fileset) enumerates a set of + regular file names given a path and pattern. + +- [`dirname`](/docs/from-1.5/functions/file/dirname) returns all of the + segments of a filesystem path _except_ the last, discarding the portion that + would be returned by `basename`.