Thanks to visit codestin.com
Credit goes to github.com

Skip to content

adds support for provider functions#162

Merged
kkozik-amplify merged 2 commits into
amplify-education:mainfrom
lkwg82:support_provider_functions
Jun 11, 2024
Merged

adds support for provider functions#162
kkozik-amplify merged 2 commits into
amplify-education:mainfrom
lkwg82:support_provider_functions

Conversation

@lkwg82

@lkwg82 lkwg82 commented Jun 6, 2024

Copy link
Copy Markdown
Contributor

adds support for parsing provider defined functions

@lkwg82 lkwg82 requested a review from a team June 6, 2024 18:30

@kkozik-amplify kkozik-amplify left a comment

Copy link
Copy Markdown
Collaborator

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

Comment thread hcl2/hcl2.lark

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: "::"

@kkozik-amplify kkozik-amplify Jun 7, 2024

Copy link
Copy Markdown
Collaborator

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

Copy link
Copy Markdown
Contributor Author

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?

Copy link
Copy Markdown
Collaborator

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!

@kkozik-amplify kkozik-amplify merged commit 04c3f6d into amplify-education:main Jun 11, 2024
@lkwg82 lkwg82 deleted the support_provider_functions branch June 13, 2024 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants