mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
expand module subdir globs
This commit is contained in:
parent
ec9c67e9ca
commit
553b8c6de5
32
internal/command/e2etest/module_archive_test.go
Normal file
32
internal/command/e2etest/module_archive_test.go
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
package e2etest
|
||||||
|
|
||||||
|
import (
|
||||||
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/hashicorp/terraform/internal/e2e"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestInitModuleArchive(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
// this fetches a module archive from github
|
||||||
|
skipIfCannotAccessNetwork(t)
|
||||||
|
|
||||||
|
fixturePath := filepath.Join("testdata", "module-archive")
|
||||||
|
tf := e2e.NewBinary(t, terraformBin, fixturePath)
|
||||||
|
|
||||||
|
stdout, stderr, err := tf.Run("init")
|
||||||
|
if err != nil {
|
||||||
|
t.Errorf("unexpected error: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if stderr != "" {
|
||||||
|
t.Errorf("unexpected stderr output:\n%s", stderr)
|
||||||
|
}
|
||||||
|
|
||||||
|
if !strings.Contains(stdout, "Terraform has been successfully initialized!") {
|
||||||
|
t.Errorf("success message is missing from output:\n%s", stdout)
|
||||||
|
}
|
||||||
|
}
|
5
internal/command/e2etest/testdata/module-archive/main.tf
vendored
Normal file
5
internal/command/e2etest/testdata/module-archive/main.tf
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
// this should be able to unpack the tarball and change the module directory to
|
||||||
|
// the archive directory regardless of its name.
|
||||||
|
module "bucket" {
|
||||||
|
source = "https://github.com/terraform-aws-modules/terraform-aws-s3-bucket/archive/v3.3.0.tar.gz//*?archive=tar.gz"
|
||||||
|
}
|
@ -587,8 +587,11 @@ func (i *ModuleInstaller) installGoGetterModule(ctx context.Context, req *earlyc
|
|||||||
return nil, diags
|
return nil, diags
|
||||||
}
|
}
|
||||||
|
|
||||||
subDir := filepath.FromSlash(addr.Subdir)
|
modDir, err := getmodules.ExpandSubdirGlobs(instPath, addr.Subdir)
|
||||||
modDir := filepath.Join(instPath, subDir)
|
if err != nil {
|
||||||
|
diags = diags.Append(err)
|
||||||
|
return nil, diags
|
||||||
|
}
|
||||||
|
|
||||||
log.Printf("[TRACE] ModuleInstaller: %s %q was downloaded to %s", key, addr, modDir)
|
log.Printf("[TRACE] ModuleInstaller: %s %q was downloaded to %s", key, addr, modDir)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user