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

several terraform functions with issues #193

Closed
kapilt opened this issue Apr 9, 2024 · 1 comment
Closed

several terraform functions with issues #193

kapilt opened this issue Apr 9, 2024 · 1 comment

Comments

@kapilt
Copy link
Contributor

kapilt commented Apr 9, 2024

func-check.zip

while testing a few functions it became apparent that there are a few functions that don't work as expected

locals {

  check_mod_path = path.module

  check_toset_int = toset([1, 2, 3])
  check_toset_str = toset(["a", "b", "c"])

  check_tomap  = tomap({ "a" = 1, "b" = 2 })
  check_tolist = tolist(["a", "b", "c"])

  check_fileexists = fileexists("${path.module}/readme.md")
  check_file       = file("${path.module}/readme.md")

  check_fileset_abs_path      = fileset("/etc/", "*")
  check_fileset_rel_path      = fileset("files", "*.py")
  check_fileset_mod_path      = fileset("${path.module}/files", "*")
  check_fileset_wild_rel_path = fileset("${path.module}", "files/*.py")

  check_trimprefix = trimprefix("abc/def", "abc")

  modules_list = toset([for lambda_main in fileset("${path.module}/modules/*/", "main.tf") : trimsuffix(trimprefix(lambda_main, "../"), "/main.tf")])
  lambdas_list = toset([for lambda_main in fileset("${path.module}/../lambdas/*/", "main.go") : trimsuffix(trimprefix(lambda_main, "../"), "/main.go")])
}

parsing this results in a few abnormalities

{
  "input_vars": {},
  "graph": {
    "locals": [
      {
        "__tfmeta": {
          "filename": "main.tf",
          "line_end": 24,
          "line_start": 2,
          "path": "locals"
        },
        "check_file": "test\n\n",
        "check_fileexists": true,
        "check_fileset_abs_path": null,
        "check_fileset_mod_path": null,
        "check_fileset_rel_path": null,
        "check_fileset_wild_rel_path": null,
        "check_mod_path": ".",
        "check_tolist": [
          "a",
          "b",
          "c"
        ],
        "check_tomap": {
          "a": 1,
          "b": 2
        },
        "check_toset_int": null,
        "check_toset_str": null,
        "check_trimprefix": "/def",
        "id": "98668bdb-5773-41a8-93cc-b6effffd5a7d",
        "lambdas_list": null,
        "modules_list": null
      }
    ]
  }
}

the toset function and fileset function both seem to have some issues.

@kapilt
Copy link
Contributor Author

kapilt commented May 20, 2024

addressed in #195

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

No branches or pull requests

1 participant