Skip to content

Parsing issues with functions #92

Open
@Jelledb

Description

Hi,

First of all thanks for developing this library.

I am trying to use this library to read out Terraform in Java and get information about for example variable names & output names.

Maybe I do not understand the intention but I'm trying my code against many public examples of Terraform like https://github.com/futurice/terraform-examples and I notice it often crashes on function calls. One example is:

...
locals {
  cleansed_prefix = replace(var.name_prefix, "/[^a-zA-Z0-9]+/", "")
}
...

where it throws an error:

java.lang.ClassCastException: class com.bertramlabs.plugins.hcl4j.symbols.HCLAttribute cannot be cast to class java.lang.String (com.bertramlabs.plugins.hcl4j.symbols.HCLAttribute is in unnamed module of loader 'app'; java.lang.String is in module java.base of loader 'bootstrap')
	at com.bertramlabs.plugins.hcl4j.HCLBaseFunctions.lambda$registerBaseFunctions$13(HCLBaseFunctions.java:218)

I had a look at the code and it crashes on the replace function.

I have two questions basically:

  • Why do you run those functions in general already at parsing time?
  • Can I somehow turn off all functions? I just want to read out some basic details of the files like input, output, provider names. I don't need all these functions to be actually run.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions