Skip to main content

No project description provided

Project description

hcl2-eval

Evaluate HCL2 configurations like a programming language. Based on hcl2-ast.

Usage

The evaluation of the HCL2 AST uses three components: A context, an evaluator an interpreter. The context is responsible for performing attribute reads and writes, looking up functions as well as opening and closing stanzas. The evaluator's responsibility is to evaluate expressions in the AST to Python values, while the interpreter executes statement nodes.

from hcl2_ast import parse_file
from hcl2_eval import Context, Evaluator, Interpreter, Stanza

class HelloStanza(Stanza):
    ...

module = parse_file(open("hello.hcl"), close=True)
context = Context.of(hello=HelloStanza)
Interpreter(Evaluator()).execute(module, context)

Check out the full example at examples/hello.py.

Compatibility

hcl2-eval requires Python 3.6 or higher.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hcl2-eval-0.1.3.tar.gz (5.5 kB view hashes)

Uploaded Source

Built Distribution

hcl2_eval-0.1.3-py3-none-any.whl (6.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page