hashicorp / hashicorp/hil

Add examples of custom variable and function lookups

Open
#9 10 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
405
Forks
32
Avg merge
23h 7m
Merged PRs (30d)
1

Description

From the conversation in https://github.com/hashicorp/hil/pull/8

It would be very useful to implement lookup functions for variables and functions without modifying HIL package code.

One example use-case would be reading arbitrary environment variables, eg.

```
greeting = "Hi ${env.NAME}"
```

This initially appeared possible by passing something that implements the [`Scope` interface](https://github.com/hashicorp/hil/blob/master/ast/scope.go#L10-L13) to the [`EvalConfig` function](https://github.com/hashicorp/hil/blob/master/example_func_test.go#L30-L31), however other parts of the code explicitly reference the `BasicScope` implementation making this not possible.

If this is already possible it would be great to document some examples in the README. If not would it be possible to allow other implementations of the `Scope` interface?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.