krabfn

package
v0.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 18, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FnFileRead = func(fs afero.Afero) function.Function {
	return function.New(
		&function.Spec{
			Params: []function.Parameter{
				{Name: "path", Type: cty.String},
			},
			Type: function.StaticReturnType(cty.String),
			Impl: func(args []cty.Value, retType cty.Type) (cty.Value, error) {
				path := args[0].AsString()
				content, err := fs.ReadFile(path)
				if err != nil {
					return cty.NilVal, err
				}
				return cty.StringVal(string(content)), nil
			},
		},
	)
}

FnFileRead reads the whole file or returns error. https://github.com/hashicorp/hcl/blob/main/guide/go_expression_eval.rst

Functions

func EvalContext

func EvalContext(fs afero.Afero) *hcl.EvalContext

EvalContext builds default EvalContext for hcl parser.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL