25 lines
541 B
Go
25 lines
541 B
Go
package paths
|
|
|
|
import (
|
|
"path/filepath"
|
|
|
|
"github.com/zclconf/go-cty/cty"
|
|
"github.com/zclconf/go-cty/cty/function"
|
|
)
|
|
|
|
func Dirname() function.Function {
|
|
return function.New(&function.Spec{
|
|
Params: []function.Parameter{
|
|
{
|
|
Name: "dirname",
|
|
Description: "Strip the filename from the path",
|
|
Type: cty.String,
|
|
},
|
|
},
|
|
Type: function.StaticReturnType(cty.String),
|
|
Impl: func(args []cty.Value, retType cty.Type) (cty.Value, error) {
|
|
return cty.StringVal(filepath.Dir(args[0].AsString())), nil
|
|
},
|
|
})
|
|
}
|