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

Handle module source subdirectories in Terraform #16160

Merged
merged 5 commits into from
Sep 26, 2017
Merged

Conversation

jbardin
Copy link
Member

@jbardin jbardin commented Sep 22, 2017

In order to remain backward compatible with some modules, we need to
handle subdirs during Load. This means duplicating part of the go-getter
code path for subDir handling so we can resolve any subDirs and globs
internally, while keeping the entire remote directory structure within
the file storage.

Module detection currently requires calling the registry to determine
the subdirectory. Since we're not directly accessing the subdirectory
through FolderStorage, and now handling it within terraform so modules can
reference sibling paths, we need to call out to the registry every
time we load a configuration to verify the subdirecory for the module,
which is returned during the Detect.

This adds a record for the detected subdirectory in the top-level of the FolderStorage path for
retrieval during Tree.Load. This lets us bypass Detection altogether,
modules can be loaded without redetecting.

Fixes #16138

Test that we can get a subdirectory from a tarball (or any other
"packed" source that we support).

The 'tar-subdir-to-parent' test highlights a regression where the
subdirectory module references a module in its parent directory. This
breaks the intended use ofr the subdirectory and the implementation in
go-getter. We need to fix this in terraform, and possible plan warnings
and deprecations for this type of source.
The registry uses the `//*` subdir format to unpack github archives. Add
a test to cover this pattern.
In order to remain backward compatible with some modules, we need to
handle subdirs during Load. This means duplicating part of the go-getter
code path for subDir handling so we can resolve any subDirs and globs
internally, while keeping the entire remote directory structure within
the file storage.
Module detection currently requires calling the registry to determine
the subdirectory. Since we're not directly accessing the subdirectory
through FolderStorage, and now handling it within terraform so modules can
reference sibling paths, we need to call out to the registry every
time we load a configuration to verify the subdirectory for the module,
which is returned during the Detect.

Record the subdirectories for each module in the top-level of the
FolderStorage path for retrieval during Tree.Load. This lets us bypass
Detection altogether, modules can be loaded without redetecting.
t.Fatal("should be loaded")
}

// This should no longer error
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure what this comment is referring to... it would be helpful to elaborate on what "this" is, and what "no longer" is in reference to (i.e. in what previous situation did it error?)

Copy link
Member Author

Choose a reason for hiding this comment

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

sorry, that was a cut&paste artifact


var testMods = map[string]testMod{
"registry/foo/bar": {
location: "file:///download/registry/foo/bar/0.2.3//*?archive=tar.gz",
Copy link
Member Author

Choose a reason for hiding this comment

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

I forgot the comment explaining the optional scheme prefix for these tests. (this fixture is likely to evolve in the near future anyway)

@jbardin jbardin merged commit d78b575 into master Sep 26, 2017
@jbardin jbardin deleted the jbardin/get-subdir branch September 26, 2017 13:23
@ghost
Copy link

ghost commented Apr 7, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0.10.6 regression: can no longer source modules from parent directory
2 participants