mirror of https://github.com/hashicorp/packer
parent
26e099023b
commit
2800043149
@ -0,0 +1,20 @@
|
||||
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
|
||||
},
|
||||
})
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
---
|
||||
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
|
||||
```
|
||||
Loading…
Reference in new issue