From 44dfa221dedeea80357ab3d61c6d5ddb14e0191a Mon Sep 17 00:00:00 2001 From: Adrien Delorme Date: Mon, 8 Jun 2020 14:59:22 +0200 Subject: [PATCH 1/3] Revert "Add template_dir function to HCL" This reverts commit 3b9a0427cdf992ff402aa4eaef1815e315a9ad83. --- hcl2template/function/templatedir.go | 18 ---------------- hcl2template/functions.go | 1 - website/data/docs-navigation.js | 1 - .../from-1.5/functions/file/template_dir.mdx | 21 ------------------- 4 files changed, 41 deletions(-) delete mode 100644 hcl2template/function/templatedir.go delete mode 100644 website/pages/docs/from-1.5/functions/file/template_dir.mdx diff --git a/hcl2template/function/templatedir.go b/hcl2template/function/templatedir.go deleted file mode 100644 index 351cda13c..000000000 --- a/hcl2template/function/templatedir.go +++ /dev/null @@ -1,18 +0,0 @@ -package function - -import ( - "github.com/zclconf/go-cty/cty" - "github.com/zclconf/go-cty/cty/function" -) - -// MakeTemplateDirFunc constructs a function that returns the directory -// in which the configuration file is located. -func MakeTemplateDirFunc(baseDir string) function.Function { - return function.New(&function.Spec{ - Params: []function.Parameter{}, - Type: function.StaticReturnType(cty.String), - Impl: func(args []cty.Value, retType cty.Type) (cty.Value, error) { - return cty.StringVal(baseDir), nil - }, - }) -} diff --git a/hcl2template/functions.go b/hcl2template/functions.go index 6af63c559..4ae0fa862 100644 --- a/hcl2template/functions.go +++ b/hcl2template/functions.go @@ -94,7 +94,6 @@ func Functions(basedir string) map[string]function.Function { "split": stdlib.SplitFunc, "strrev": stdlib.ReverseFunc, "substr": stdlib.SubstrFunc, - "template_dir": pkrfunction.MakeTemplateDirFunc(basedir), "timestamp": pkrfunction.TimestampFunc, "timeadd": stdlib.TimeAddFunc, "title": stdlib.TitleFunc, diff --git a/website/data/docs-navigation.js b/website/data/docs-navigation.js index 5afb3d00a..ebea2b6f9 100644 --- a/website/data/docs-navigation.js +++ b/website/data/docs-navigation.js @@ -113,7 +113,6 @@ export default [ 'fileset', 'pathexpand', 'pwd', - 'template_dir', ], }, { diff --git a/website/pages/docs/from-1.5/functions/file/template_dir.mdx b/website/pages/docs/from-1.5/functions/file/template_dir.mdx deleted file mode 100644 index ecad93176..000000000 --- a/website/pages/docs/from-1.5/functions/file/template_dir.mdx +++ /dev/null @@ -1,21 +0,0 @@ ---- -layout: docs -page_title: template_dir - Functions - Configuration Language -sidebar_title: template_dir -description: The template_dir function returns the directory in which the configuration file is located. ---- - -# `template_dir` Function - -`template_dir` returns the directory in which the configuration file is located. - -```hcl -template_dir() -``` - -## Examples - -```shell-session -> template_dir() -packer -``` From cf6eca7e1c9fc4b151e05c2f57b41648e6b5735b Mon Sep 17 00:00:00 2001 From: Adrien Delorme Date: Mon, 8 Jun 2020 14:59:27 +0200 Subject: [PATCH 2/3] Revert "Add pwd function to HCL" This reverts commit 28000431492f835912a785bd8a93f86ae590a041. --- hcl2template/function/pwd.go | 20 ------------------ hcl2template/functions.go | 1 - website/data/docs-navigation.js | 1 - .../docs/from-1.5/functions/file/pwd.mdx | 21 ------------------- 4 files changed, 43 deletions(-) delete mode 100644 hcl2template/function/pwd.go delete mode 100644 website/pages/docs/from-1.5/functions/file/pwd.mdx diff --git a/hcl2template/function/pwd.go b/hcl2template/function/pwd.go deleted file mode 100644 index 64948d838..000000000 --- a/hcl2template/function/pwd.go +++ /dev/null @@ -1,20 +0,0 @@ -package function - -import ( - "os" - - "github.com/zclconf/go-cty/cty" - "github.com/zclconf/go-cty/cty/function" -) - -// MakePwdFunc constructs a function that returns the working directory as a string. -func MakePwdFunc() function.Function { - return function.New(&function.Spec{ - Params: []function.Parameter{}, - Type: function.StaticReturnType(cty.String), - Impl: func(args []cty.Value, retType cty.Type) (cty.Value, error) { - dir, err := os.Getwd() - return cty.StringVal(dir), err - }, - }) -} diff --git a/hcl2template/functions.go b/hcl2template/functions.go index 4ae0fa862..821c525ba 100644 --- a/hcl2template/functions.go +++ b/hcl2template/functions.go @@ -76,7 +76,6 @@ func Functions(basedir string) map[string]function.Function { "parseint": stdlib.ParseIntFunc, "pathexpand": filesystem.PathExpandFunc, "pow": stdlib.PowFunc, - "pwd": pkrfunction.MakePwdFunc(), "range": stdlib.RangeFunc, "reverse": stdlib.ReverseFunc, "replace": stdlib.ReplaceFunc, diff --git a/website/data/docs-navigation.js b/website/data/docs-navigation.js index ebea2b6f9..e0ceac5a7 100644 --- a/website/data/docs-navigation.js +++ b/website/data/docs-navigation.js @@ -112,7 +112,6 @@ export default [ 'fileexists', 'fileset', 'pathexpand', - 'pwd', ], }, { diff --git a/website/pages/docs/from-1.5/functions/file/pwd.mdx b/website/pages/docs/from-1.5/functions/file/pwd.mdx deleted file mode 100644 index ef2bafe28..000000000 --- a/website/pages/docs/from-1.5/functions/file/pwd.mdx +++ /dev/null @@ -1,21 +0,0 @@ ---- -layout: docs -page_title: pwd - Functions - Configuration Language -sidebar_title: pwd -description: The pwd function returns the working directory while executing Packer. ---- - -# `pwd` Function - -`pwd` returns the working directory while executing Packer. - -```hcl -pwd() -``` - -## Examples - -```shell-session -> pwd() -/home/user/some/packer -``` From eeabae88e31d4558e1b096c1388c2c31a56af813 Mon Sep 17 00:00:00 2001 From: Adrien Delorme Date: Mon, 8 Jun 2020 15:29:45 +0200 Subject: [PATCH 3/3] Update abspath.mdx --- .../pages/docs/from-1.5/functions/file/abspath.mdx | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/website/pages/docs/from-1.5/functions/file/abspath.mdx b/website/pages/docs/from-1.5/functions/file/abspath.mdx index 922cdb819..6398fe8c9 100644 --- a/website/pages/docs/from-1.5/functions/file/abspath.mdx +++ b/website/pages/docs/from-1.5/functions/file/abspath.mdx @@ -11,11 +11,12 @@ description: The abspath function converts the argument to an absolute filesyste to an absolute path. That is, if the path is not absolute, it will be joined with the current working directory. -Referring directly to filesystem paths in resource arguments may cause -spurious diffs if the same configuration is applied from multiple systems or on -different host operating systems. We recommend using filesystem paths only -for transient values, such as the argument to [`file`](/docs/from-1.5/functions/file) (where -only the contents are then stored) or in `connection` and `provisioner` blocks. +Referring directly to filesystem paths in resource arguments may cause spurious +diffs if the same configuration is applied from multiple systems or on +different host operating systems. We recommend using filesystem paths only for +transient values, such as the argument to +[`file`](/docs/from-1.5/functions/file) (where only the contents are then +stored). ## Examples