-
Notifications
You must be signed in to change notification settings - Fork 56
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
adds support for provider functions #162
adds support for provider functions #162
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @lkwg82, thanks a lot for contributing.
I left a comment about one minor thing. Overall the PR looks good
@@ -55,6 +56,8 @@ heredoc_template_trim : /<<-(?P<heredoc_trim>[a-zA-Z][a-zA-Z0-9._-]+)\n(?:.|\n)* | |||
|
|||
function_call : identifier "(" new_line_or_comment? arguments? new_line_or_comment? ")" | |||
arguments : (expression (new_line_or_comment* "," new_line_or_comment* expression)* ("," | "...")? new_line_or_comment*) | |||
colons: "::" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this definition and use ::
directly in provider_function_call
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont get it done, everytime I inline "::" I get this error:
FAIL: test_load_terraform_from_cache:10
'provider_function.tf' (test.unit.test_load.TestLoad.test_load_terraform_from_cache:10
'provider_function.tf')
----------------------------------------------------------------------
Traceback (most recent call last):
File ".../python-hcl2/.tox/py312-unit/lib/python3.12/site-packages/lark/visitors.py", line 124, in _call_userfunc
return f(children)
^^^^^^^^^^^
TypeError: sequence item 1: expected str instance, Tree found
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File ".../python-hcl2/test/unit/test_load.py", line 43, in check_terraform
hcl2_dict = hcl2.load(hcl_file)
^^^^^^^^^^^^^^^^^^^
lark.exceptions.VisitError: Error trying to process rule "provider_function_call":
sequence item 1: expected str instance, Tree found
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File ".../python-hcl2/test/unit/test_load.py", line 45, in check_terraform
assert False, f"failed to tokenize terraform in `{hcl_path_str}`: {exc}"
^^^^^
AssertionError: failed to tokenize terraform in `provider_function.tf`: Error trying to process rule "provider_function_call":
sequence item 1: expected str instance, Tree found
I'm not so fluent, maybe someone could assist?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looked into that and this happens because of how the provider_function_call
works. This function is consistent with function_call
you seemed to base on so let's stick to the implementation you proposed.
Thanks!
adds support for parsing provider defined functions