diff --git a/config/module/detect.go b/config/module/detect.go index 36a34632f3..0021c0a9f6 100644 --- a/config/module/detect.go +++ b/config/module/detect.go @@ -48,9 +48,16 @@ func Detect(src string, pwd string) (string, error) { continue } - // Preserve the forced getter if it exists + var detectForce string + detectForce, result = getForcedGetter(result) + + // Preserve the forced getter if it exists. We try to use the + // original set force first, followed by any force set by the + // detector. if getForce != "" { result = fmt.Sprintf("%s::%s", getForce, result) + } else if detectForce != "" { + result = fmt.Sprintf("%s::%s", detectForce, result) } return result, nil diff --git a/config/module/detect_test.go b/config/module/detect_test.go index 5fdf5dc74f..8f62f6618b 100644 --- a/config/module/detect_test.go +++ b/config/module/detect_test.go @@ -13,6 +13,7 @@ func TestDetect(t *testing.T) { }{ {"./foo", "/foo", "file:///foo/foo", false}, {"git::./foo", "/foo", "git::file:///foo/foo", false}, + {"git::github.com/hashicorp/foo", "", "git::https://github.com/hashicorp/foo.git", false}, } for i, tc := range cases {