Skip to content

Commit

Permalink
add check for submodules
Browse files Browse the repository at this point in the history
Signed-off-by: sk593 <[email protected]>
  • Loading branch information
sk593 committed Jan 22, 2024
1 parent 37e66e2 commit 0b8a53e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkg/recipes/terraform/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ func inspectModule(workingDir, localModuleName string, templatePath string) (*mo
// https://developer.hashicorp.com/terraform/tutorials/modules/module-use#understand-how-modules-work
//
// If the template path is for a submodule, we'll add the submodule path to the module root directory.
if strings.Contains(templatePath, "//") {
moduleRootDir += "/" + strings.Split(templatePath, "//")[1]
subModDex := strings.LastIndex(templatePath, "//")
// Make sure that we don't mistake the double slashes in a '://' scheme as a submodule indicator
if subModDex != -1 && templatePath[subModDex-1:subModDex+len("//")] != "://" {
moduleRootDir += "/" + templatePath[subModDex+len("//"):]
}
mod, diags := tfconfig.LoadModule(filepath.Join(workingDir, moduleRootDir))
if diags.HasErrors() {
Expand Down

0 comments on commit 0b8a53e

Please sign in to comment.