-
Notifications
You must be signed in to change notification settings - Fork 135
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
walker: Index uninitialized modules #997
Conversation
0070b7c
to
4836a47
Compare
0ff6d0c
to
25b160f
Compare
25b160f
to
496417c
Compare
a4f6e82
to
1297b5c
Compare
f270fc9
to
861e1cc
Compare
Replacing `filepath.Walk` with `fs.WalkDir`: - makes testing of the walker easier with `testing/fstest`, or any other `fs.FS` compatible libraries. - makes walker aligned with the FS interpretation of the rest of the codebase in that open documents are served from in-memory cache, not from disk - allows for slightly more readable code
This was actually required since the introduction of io/fs or `os.Readdir()` into filesystem package (introduced only in 1.16), so this is just retrospective. https://pkg.go.dev/io/fs https://pkg.go.dev/os#ReadDir
3ebb8e0
to
568af4d
Compare
Checking MetaState in (ModuleStore).LocalModuleMeta prevents a possible race condition where terraform-schema would otherwise build out module schema just because the module entry is present, but metadata was not parsed yet.
568af4d
to
decc54b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! This is really fast & fun to use.
I tried different numbers of modules and couldn't see any performance impact
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
Fixes #724
Depends on hashicorp/terraform-schema#126The PR changes the walker such that it indexes any directory it finds with >0
*.tf
files in it. This has a few side effects I had to account for:Defer
to provide that guarantee..terraform
dir without other files would trigger indexing, but the new behaviour is more correct in not indexing such a directory. The reason we start with empty directory with just.terraform
is because it means we can more easily provide the actual test configuration as part of the test viadidOpen
and we don't have to deal with copying/creating test configs in FS.empty.tf
initialize
, but that would also mean we have to find a different way of loading the schema, e.g. by inserting it into memdb as part of each test.Indexing Before
Indexing After
I filed a few follow-up issues to deal with the potential performance hit resulting from indexing more modules:
required_version
constraint #993