diff options
Diffstat (limited to 'vendor/github.com/hashicorp/go-getter/client.go')
-rw-r--r-- | vendor/github.com/hashicorp/go-getter/client.go | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/vendor/github.com/hashicorp/go-getter/client.go b/vendor/github.com/hashicorp/go-getter/client.go index 876812a..300301c 100644 --- a/vendor/github.com/hashicorp/go-getter/client.go +++ b/vendor/github.com/hashicorp/go-getter/client.go | |||
@@ -17,6 +17,7 @@ import ( | |||
17 | "strings" | 17 | "strings" |
18 | 18 | ||
19 | urlhelper "github.com/hashicorp/go-getter/helper/url" | 19 | urlhelper "github.com/hashicorp/go-getter/helper/url" |
20 | "github.com/hashicorp/go-safetemp" | ||
20 | ) | 21 | ) |
21 | 22 | ||
22 | // Client is a client for downloading things. | 23 | // Client is a client for downloading things. |
@@ -100,17 +101,14 @@ func (c *Client) Get() error { | |||
100 | dst := c.Dst | 101 | dst := c.Dst |
101 | src, subDir := SourceDirSubdir(src) | 102 | src, subDir := SourceDirSubdir(src) |
102 | if subDir != "" { | 103 | if subDir != "" { |
103 | tmpDir, err := ioutil.TempDir("", "tf") | 104 | td, tdcloser, err := safetemp.Dir("", "getter") |
104 | if err != nil { | 105 | if err != nil { |
105 | return err | 106 | return err |
106 | } | 107 | } |
107 | if err := os.RemoveAll(tmpDir); err != nil { | 108 | defer tdcloser.Close() |
108 | return err | ||
109 | } | ||
110 | defer os.RemoveAll(tmpDir) | ||
111 | 109 | ||
112 | realDst = dst | 110 | realDst = dst |
113 | dst = tmpDir | 111 | dst = td |
114 | } | 112 | } |
115 | 113 | ||
116 | u, err := urlhelper.Parse(src) | 114 | u, err := urlhelper.Parse(src) |
@@ -232,7 +230,18 @@ func (c *Client) Get() error { | |||
232 | // Destination is the base name of the URL path in "any" mode when | 230 | // Destination is the base name of the URL path in "any" mode when |
233 | // a file source is detected. | 231 | // a file source is detected. |
234 | if mode == ClientModeFile { | 232 | if mode == ClientModeFile { |
235 | dst = filepath.Join(dst, filepath.Base(u.Path)) | 233 | filename := filepath.Base(u.Path) |
234 | |||
235 | // Determine if we have a custom file name | ||
236 | if v := q.Get("filename"); v != "" { | ||
237 | // Delete the query parameter if we have it. | ||
238 | q.Del("filename") | ||
239 | u.RawQuery = q.Encode() | ||
240 | |||
241 | filename = v | ||
242 | } | ||
243 | |||
244 | dst = filepath.Join(dst, filename) | ||
236 | } | 245 | } |
237 | } | 246 | } |
238 | 247 | ||
@@ -305,7 +314,13 @@ func (c *Client) Get() error { | |||
305 | return err | 314 | return err |
306 | } | 315 | } |
307 | 316 | ||
308 | return copyDir(realDst, filepath.Join(dst, subDir), false) | 317 | // Process any globs |
318 | subDir, err := SubdirGlob(dst, subDir) | ||
319 | if err != nil { | ||
320 | return err | ||
321 | } | ||
322 | |||
323 | return copyDir(realDst, subDir, false) | ||
309 | } | 324 | } |
310 | 325 | ||
311 | return nil | 326 | return nil |