Merge pull request #9372 from hashicorp/azr-hcl2-revert-template_dir-and-pwd

HCL2: Revert adding template_dir and pwd funcs
This commit is contained in:
Adrien Delorme 2020-06-08 15:50:53 +02:00 committed by GitHub
commit c97619459a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 6 additions and 89 deletions

View File

@ -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
},
})
}

View File

@ -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
},
})
}

View File

@ -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,
@ -94,7 +93,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,

View File

@ -112,8 +112,6 @@ export default [
'fileexists',
'fileset',
'pathexpand',
'pwd',
'template_dir',
],
},
{

View File

@ -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

View File

@ -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
```

View File

@ -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
```