diff --git a/client.go b/client.go index 1832f17b0..ff759a5d7 100644 --- a/client.go +++ b/client.go @@ -13,6 +13,7 @@ import ( "io/ioutil" "os" "path/filepath" + "strconv" "strings" urlhelper "github.com/hashicorp/go-getter/helper/url" @@ -126,6 +127,12 @@ func (c *Client) Get() error { if archiveV != "" { q.Del("archive") u.RawQuery = q.Encode() + + // If we can parse the value as a bool and it is false, then + // set the archive to "-" which should never map to a decompressor + if b, err := strconv.ParseBool(archiveV); err == nil && !b { + archiveV = "-" + } } if archiveV == "" { // We don't appear to... but is it part of the filename? diff --git a/get_test.go b/get_test.go index 523a41296..fc758df54 100644 --- a/get_test.go +++ b/get_test.go @@ -137,6 +137,23 @@ func TestGetFile_archiveChecksum(t *testing.T) { assertContents(t, dst, "Hello\n") } +func TestGetFile_archiveNoUnarchive(t *testing.T) { + dst := tempFile(t) + u := testModule("basic-file-archive/archive.tar.gz") + u += "?archive=false" + + if err := GetFile(dst, u); err != nil { + t.Fatalf("err: %s", err) + } + + // Verify the main file exists + actual := testMD5(t, dst) + expected := "fbd90037dacc4b1ab40811d610dde2f0" + if actual != expected { + t.Fatalf("bad: %s", actual) + } +} + func TestGetFile_checksum(t *testing.T) { cases := []struct { Append string