Skip to content

Commit

Permalink
false archive flag disables unarchiving
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchellh committed Jan 12, 2016
1 parent 06b4e99 commit 21cfd42
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
7 changes: 7 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"io/ioutil"
"os"
"path/filepath"
"strconv"
"strings"

urlhelper "github.com/hashicorp/go-getter/helper/url"
Expand Down Expand Up @@ -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?
Expand Down
17 changes: 17 additions & 0 deletions get_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 21cfd42

Please sign in to comment.