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: incorrect globals conflict handling #745

Merged
merged 7 commits into from
Dec 7, 2022
Merged

Conversation

i4ki
Copy link
Contributor

@i4ki i4ki commented Dec 7, 2022

Reason for This Change

The fix #738 introduced a bug in the globals conflict checks.
It can be reproduced with the configuration below:

# modules/imported.tm
globals hello {
    world = {
       a = 1
    }
}
# /file.tm
import {
    source = "/modules/imported.tm"
}

globals hello world {
    a = 2
}

When running Terramate it gives the error below:

global eval: terramate schema error: global.hello.world.a attribute redefined: previously defined at /

The reason is that when fixing #738 we switched to store the "config dir" in the eval.Object values because it was needed to solve the problem but the check for conflicting attributes (at runtime) needs the actual source file (not from where it's being imported).

Description of Changes

The fix just stores both the configuration dir and the origin source path in the eval.Object.

@codecov
Copy link

codecov bot commented Dec 7, 2022

Codecov Report

Base: 72.02% // Head: 72.07% // Increases project coverage by +0.04% 🎉

Coverage data is based on head (b75c580) compared to base (abebe36).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #745      +/-   ##
==========================================
+ Coverage   72.02%   72.07%   +0.04%     
==========================================
  Files          73       73              
  Lines       12116    12127      +11     
==========================================
+ Hits         8727     8740      +13     
+ Misses       3050     3049       -1     
+ Partials      339      338       -1     
Flag Coverage Δ
tests 72.07% <100.00%> (+0.04%) ⬆️

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

Impacted Files Coverage Δ
globals/eval_report.go 100.00% <100.00%> (ø)
globals/globals.go 94.73% <100.00%> (+0.17%) ⬆️
hcl/eval/object.go 90.79% <100.00%> (ø)
stack/clone.go 75.22% <0.00%> (+1.76%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@katcipis katcipis self-requested a review December 7, 2022 10:47
hcl/eval/object.go Outdated Show resolved Hide resolved
hcl/eval/object.go Outdated Show resolved Hide resolved
hcl/eval/object_test.go Outdated Show resolved Hide resolved
hcl/eval/object.go Outdated Show resolved Hide resolved
katcipis
katcipis previously approved these changes Dec 7, 2022
Copy link
Contributor

@katcipis katcipis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀 🚀 🚀

@i4ki i4ki requested a review from katcipis December 7, 2022 11:56
@i4ki i4ki merged commit 5251535 into main Dec 7, 2022
@i4ki i4ki deleted the i4k-fix-globals-redefined branch December 7, 2022 13:43
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.

None yet

2 participants