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

fix: evaluate only globals already known #136

Merged
merged 1 commit into from
Jan 5, 2022

Conversation

mariux
Copy link
Contributor

@mariux mariux commented Jan 5, 2022

  • detect unknown namespaces
  • detect unknown variables in global namespace
  • fix evaluation order
  • detect global variables that could not be evaluated (cycles)
  • set new context in each loop execution

@codecov-commenter
Copy link

Codecov Report

Merging #136 (df1430e) into main (0012dde) will decrease coverage by 0.49%.
The diff coverage is 62.06%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #136      +/-   ##
==========================================
- Coverage   74.29%   73.79%   -0.50%     
==========================================
  Files          29       29              
  Lines        3077     3103      +26     
==========================================
+ Hits         2286     2290       +4     
- Misses        593      609      +16     
- Partials      198      204       +6     
Flag Coverage Δ
tests 73.79% <62.06%> (-0.50%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
globals.go 79.41% <59.25%> (-12.56%) ⬇️
hcl/eval/eval.go 82.85% <100.00%> (+1.03%) ⬆️
manager.go 50.51% <0.00%> (-0.52%) ⬇️
git/git.go 65.89% <0.00%> (-0.52%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0012dde...df1430e. Read the comment docs.

@mariux mariux force-pushed the mariux/fix-global-evaluation branch from df1430e to fc7fc42 Compare January 5, 2022 00:46
@katcipis
Copy link
Contributor

katcipis commented Jan 5, 2022

Tested with:

#!/bin/bash

set -o errexit
set -o nounset

basedir=$(mktemp -d)

cd "${basedir}"

cat > terramate.tm.hcl <<- EOM
terramate {
  config {
  }
}
EOM

mkdir -p dir/stack

cat > dir/stack/terramate.tm.hcl <<- EOM
globals {
  team = {
    members = ["aaa"]
  }
  members = global.team.members
  members_try = try(global.team.members, [])
}

export_as_locals {
  members = global.members
  members_try = global.members_try
}

stack {}
EOM

terramate generate

echo
echo "generated code"
cat dir/stack/_gen_locals.tm.tf

echo
echo "listing globals"
terramate stacks globals

And it seems to be working now, thanks 💯

@mariux mariux merged commit fe1006f into main Jan 5, 2022
@mariux mariux deleted the mariux/fix-global-evaluation branch January 5, 2022 15:12
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.

4 participants