Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hclwrite: Allow constructing expressions from raw tokens #320

Merged
merged 1 commit into from
Nov 19, 2019

Conversation

apparentlymart
Copy link
Contributor

We currently have functions for constructing new expressions from either constant values or from traversals, but some surgical updates require producing a more complex expression.

In the long run perhaps we'll have some mechanism for constructing valid expressions via a high-level AST-like API, similar to what we already have for structural constructs, but as a simpler first step here we add a mechanism to just write raw tokens directly into an expression, with the caller being responsible for making sure those tokens represent valid HCL expression syntax.

Since this new API treats the given tokens as unstructured, the resulting expression can't fully support the whole of the expression API, but it's good enough for writing in complex expressions without disturbing existing content elsewhere in the input file.

We currently have functions for constructing new expressions from either
constant values or from traversals, but some surgical updates require
producing a more complex expression.

In the long run perhaps we'll have some mechanism for constructing valid
expressions via a high-level AST-like API, similar to what we already have
for structural constructs, but as a simpler first step here we add a
mechanism to just write raw tokens directly into an expression, with the
caller being responsible for making sure those tokens represent valid
HCL expression syntax.

Since this new API treats the given tokens as unstructured, the resulting
expression can't fully support the whole of the expression API, but it's
good enough for writing in complex expressions without disturbing existing
content elsewhere in the input file.
@apparentlymart apparentlymart added enhancement v2 Relates to the v2 line of releases hclwrite labels Nov 19, 2019
@apparentlymart apparentlymart self-assigned this Nov 19, 2019
Copy link
Member

@jbardin jbardin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, and anticipating finding out soon what this is going to be used for!

@apparentlymart apparentlymart merged commit 0698578 into hcl2 Nov 19, 2019
@apparentlymart apparentlymart deleted the f-hclwrite-setattributeraw branch November 19, 2019 23:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement hclwrite v2 Relates to the v2 line of releases
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants