terramate-io / terramate

Terramate CLI is an open-source Infrastructure as Code (IaC) Orchestration and Code Generation tool for Terraform, OpenTofu and Terragrunt.
https://terramate.io
Mozilla Public License 2.0
3.28k stars 92 forks source link

chore: use hasUnknowns from partialEval. #1948

Open i4ki opened 1 month ago

i4ki commented 1 month ago

What this PR does / why we need it:

The partial evaluator returns a hasUnknowns boolean that can be used by the tm_ternary() to figure if unknowns are still present in the expr, then we can avoid walking the resulted expression.

Which issue(s) this PR fixes:

none

Special notes for your reviewer:

Does this PR introduce a user-facing change?

no
github-actions[bot] commented 1 month ago
2024/10/24 17:00:34 Terraform detected version: 1.9.7
toolsetPath: /tmp/cmd-terramate-test-1229993323
=== RUN   TestInteropCloudSyncPreview
=== RUN   TestInteropCloudSyncPreview/preview:_basic-drift
    interoperability_test.go:46: using GITHUB_EVENT_FILE=/home/runner/work/_temp/_github_workflow/event.json
=== RUN   TestInteropCloudSyncPreview/preview:_basic-drift-uppercase-id
    interoperability_test.go:46: using GITHUB_EVENT_FILE=/home/runner/work/_temp/_github_workflow/event.json
--- PASS: TestInteropCloudSyncPreview (11.54s)
    --- PASS: TestInteropCloudSyncPreview/preview:_basic-drift (5.97s)
    --- PASS: TestInteropCloudSyncPreview/preview:_basic-drift-uppercase-id (5.57s)
=== RUN   TestInteropSyncDeployment
=== RUN   TestInteropSyncDeployment/deployment:_empty
=== RUN   TestInteropSyncDeployment/deployment:_empty-uppercase-id
--- PASS: TestInteropSyncDeployment (37.72s)
    --- PASS: TestInteropSyncDeployment/deployment:_empty (18.96s)
    --- PASS: TestInteropSyncDeployment/deployment:_empty-uppercase-id (18.76s)
=== RUN   TestInteropDrift
=== RUN   TestInteropDrift/drift:_basic-drift
=== RUN   TestInteropDrift/drift:_basic-drift-uppercase-id
--- PASS: TestInteropDrift (60.80s)
    --- PASS: TestInteropDrift/drift:_basic-drift (30.20s)
    --- PASS: TestInteropDrift/drift:_basic-drift-uppercase-id (30.60s)
PASS
ok      github.com/terramate-io/terramate/e2etests/cloud/interop    169.204s
github-actions[bot] commented 1 month ago

Preview of ubuntu-focal/go1.21 tests in 2beef3ea799be8580334d28d99e429980a11ee6d

:mag: View Details on Terramate Cloud

hcl/eval
stdlib
github-actions[bot] commented 1 month ago

Preview of macos-ventura/go1.21 tests in 2beef3ea799be8580334d28d99e429980a11ee6d

:mag: View Details on Terramate Cloud

hcl/eval
stdlib
github-actions[bot] commented 1 month ago
metric: time/op
ChangeDetection-4: old 4.00ms ± 4%: new 3.93ms ± 5%: delta: -1.63%
ChangeDetectionTFAndTG-4: old 12.7ms ± 3%: new 12.6ms ± 5%: delta: 0.00%
CloudReadLines-4: old 986µs ± 4%: new 1001µs ± 7%: delta: 0.00%
CloudReadLine-4: old 7.26ms ± 3%: new 7.18ms ± 2%: delta: 0.00%
ListFiles-4: old 80.1µs ± 1%: new 79.9µs ± 1%: delta: -0.26%
Generate-4: old 1.55s ± 4%: new 1.54s ± 4%: delta: 0.00%
GenerateRegex-4: old 1.06s ± 6%: new 1.06s ± 3%: delta: 0.00%
TokensForExpressionComplex-4: old 1.26ms ± 1%: new 1.25ms ± 1%: delta: 0.00%
TokensForExpressionPlainStringNoNewline-4: old 792ns ± 1%: new 792ns ± 1%: delta: 0.00%
TokensForExpressionStringWith100Newlines-4: old 23.8µs ± 2%: new 23.6µs ± 1%: delta: -1.02%
TokensForExpressionObjectWith100KeysWithNumberValues-4: old 1.45ms ± 0%: new 1.45ms ± 2%: delta: 0.00%
TokensForExpression-4: old 1.26ms ± 0%: new 1.26ms ± 2%: delta: 0.00%
PartialEvalComplex-4: old 540µs ± 1%: new 537µs ± 1%: delta: -0.60%
PartialEvalSmallString-4: old 3.90µs ± 1%: new 4.01µs ± 1%: delta: 2.80%
PartialEvalHugeString-4: old 1.92ms ± 1%: new 1.93ms ± 1%: delta: 0.76%
PartialEvalHugeInterpolatedString-4: old 4.94ms ± 2%: new 4.92ms ± 3%: delta: -0.48%
PartialEvalObject-4: old 26.9µs ± 1%: new 26.3µs ± 1%: delta: -2.22%
TmAllTrueLiteralList-4: old 619µs ± 1%: new 621µs ± 2%: delta: 0.00%
TmAllTrueFuncall-4: old 20.4µs ± 1%: new 20.6µs ± 2%: delta: 0.98%
TmAnyTrueLiteralList-4: old 4.88ms ± 1%: new 4.94ms ± 1%: delta: 1.20%
TmAnyTrueFuncall-4: old 20.8µs ± 1%: new 20.9µs ± 2%: delta: 0.59%
TmTernary-4: old 2.52µs ± 1%: new 2.22µs ± 2%: delta: -12.09%
TmTryUnknownFunc-4: old 2.29µs ± 1%: new 2.30µs ± 1%: delta: 0.57%
TmTryUnknownVariable-4: old 2.19µs ± 1%: new 2.20µs ± 2%: delta: 0.00%
TmTryUnknownObjectKey-4: old 2.48µs ± 0%: new 2.50µs ± 1%: delta: 0.83%
metric: alloc/op
ChangeDetection-4: old 357kB ± 0%: new 357kB ± 0%: delta: 0.00%
ChangeDetectionTFAndTG-4: old 4.80MB ± 0%: new 4.80MB ± 0%: delta: 0.00%
CloudReadLines-4: old 3.12MB ± 0%: new 3.12MB ± 0%: delta: 0.00%
CloudReadLine-4: old 3.37MB ± 0%: new 3.37MB ± 0%: delta: 0.00%
ListFiles-4: old 27.6kB ± 0%: new 27.6kB ± 0%: delta: 0.00%
Generate-4: old 2.24GB ± 0%: new 2.24GB ± 0%: delta: 0.00%
GenerateRegex-4: old 926MB ± 0%: new 926MB ± 0%: delta: 0.00%
TokensForExpressionComplex-4: old 394kB ± 0%: new 394kB ± 0%: delta: 0.00%
TokensForExpressionPlainStringNoNewline-4: old 512B ± 0%: new 512B ± 0%: delta: 0.00%
TokensForExpressionStringWith100Newlines-4: old 12.5kB ± 0%: new 12.5kB ± 0%: delta: 0.00%
TokensForExpressionObjectWith100KeysWithNumberValues-4: old 395kB ± 0%: new 395kB ± 0%: delta: -0.00%
TokensForExpression-4: old 395kB ± 0%: new 394kB ± 0%: delta: 0.00%
PartialEvalComplex-4: old 361kB ± 0%: new 361kB ± 0%: delta: -0.00%
PartialEvalSmallString-4: old 1.95kB ± 0%: new 1.95kB ± 0%: delta: 0.00%
PartialEvalHugeString-4: old 196kB ± 0%: new 196kB ± 0%: delta: 0.00%
PartialEvalHugeInterpolatedString-4: old 4.31MB ± 0%: new 4.31MB ± 0%: delta: 0.00%
PartialEvalObject-4: old 19.4kB ± 0%: new 19.4kB ± 0%: delta: 0.00%
TmAllTrueLiteralList-4: old 321kB ± 0%: new 321kB ± 0%: delta: -0.00%
TmAllTrueFuncall-4: old 10.6kB ± 0%: new 10.6kB ± 0%: delta: 0.00%
TmAnyTrueLiteralList-4: old 2.09MB ± 0%: new 2.09MB ± 0%: delta: 0.00%
TmAnyTrueFuncall-4: old 10.7kB ± 0%: new 10.7kB ± 0%: delta: 0.00%
TmTernary-4: old 1.18kB ± 0%: new 1.00kB ± 0%: delta: -15.54%
TmTryUnknownFunc-4: old 784B ± 0%: new 784B ± 0%: delta: 0.00%
TmTryUnknownVariable-4: old 768B ± 0%: new 768B ± 0%: delta: 0.00%
TmTryUnknownObjectKey-4: old 952B ± 0%: new 952B ± 0%: delta: 0.00%
metric: allocs/op
ChangeDetection-4: old 2.43k ± 0%: new 2.43k ± 0%: delta: 0.00%
ChangeDetectionTFAndTG-4: old 33.6k ± 0%: new 33.6k ± 0%: delta: 0.00%
CloudReadLines-4: old 5.54k ± 0%: new 5.54k ± 0%: delta: 0.00%
CloudReadLine-4: old 60.0k ± 0%: new 60.0k ± 0%: delta: 0.00%
ListFiles-4: old 335 ± 0%: new 335 ± 0%: delta: 0.00%
Generate-4: old 25.7M ± 0%: new 25.7M ± 0%: delta: 0.00%
GenerateRegex-4: old 18.4M ± 0%: new 18.4M ± 0%: delta: 0.00%
TokensForExpressionComplex-4: old 4.83k ± 0%: new 4.83k ± 0%: delta: 0.00%
TokensForExpressionPlainStringNoNewline-4: old 20.0 ± 0%: new 20.0 ± 0%: delta: 0.00%
TokensForExpressionStringWith100Newlines-4: old 227 ± 0%: new 227 ± 0%: delta: 0.00%
TokensForExpressionObjectWith100KeysWithNumberValues-4: old 3.19k ± 0%: new 3.19k ± 0%: delta: 0.00%
TokensForExpression-4: old 4.83k ± 0%: new 4.83k ± 0%: delta: 0.00%
PartialEvalComplex-4: old 3.78k ± 0%: new 3.78k ± 0%: delta: 0.00%
PartialEvalSmallString-4: old 26.0 ± 0%: new 26.0 ± 0%: delta: 0.00%
PartialEvalHugeString-4: old 38.0 ± 0%: new 38.0 ± 0%: delta: 0.00%
PartialEvalHugeInterpolatedString-4: old 26.1k ± 0%: new 26.1k ± 0%: delta: 0.00%
PartialEvalObject-4: old 183 ± 0%: new 183 ± 0%: delta: 0.00%
TmAllTrueLiteralList-4: old 5.94k ± 0%: new 5.94k ± 0%: delta: 0.00%
TmAllTrueFuncall-4: old 275 ± 0%: new 275 ± 0%: delta: 0.00%
TmAnyTrueLiteralList-4: old 59.6k ± 0%: new 59.6k ± 0%: delta: 0.00%
TmAnyTrueFuncall-4: old 277 ± 0%: new 277 ± 0%: delta: 0.00%
TmTernary-4: old 27.0 ± 0%: new 20.0 ± 0%: delta: -25.93%
TmTryUnknownFunc-4: old 21.0 ± 0%: new 21.0 ± 0%: delta: 0.00%
TmTryUnknownVariable-4: old 20.0 ± 0%: new 20.0 ± 0%: delta: 0.00%
TmTryUnknownObjectKey-4: old 23.0 ± 0%: new 23.0 ± 0%: delta: 0.00%