8 "github.com/hashicorp/go-getter"
11 // GetMode is an enum that describes how modules are loaded.
13 // GetModeLoad says that modules will not be downloaded or updated, they will
14 // only be loaded from the storage.
16 // GetModeGet says that modules can be initially downloaded if they don't
17 // exist, but otherwise to just load from the current version in storage.
19 // GetModeUpdate says that modules should be checked for updates and
20 // downloaded prior to loading. If there are no updates, we load the version
21 // from disk, otherwise we download first and then load.
25 GetModeNone GetMode = iota
30 // GetCopy is the same as Get except that it downloads a copy of the
31 // module represented by source.
33 // This copy will omit and dot-prefixed files (such as .git/, .hg/) and
34 // can't be updated on its own.
35 func GetCopy(dst, src string) error {
36 // Create the temporary directory to do the real Get to
37 tmpDir, err := ioutil.TempDir("", "tf")
41 defer os.RemoveAll(tmpDir)
43 tmpDir = filepath.Join(tmpDir, "module")
45 // Get to that temporary dir
46 if err := getter.Get(tmpDir, src); err != nil {
50 // Make sure the destination exists
51 if err := os.MkdirAll(dst, 0755); err != nil {
55 // Copy to the final location
56 return copyDir(dst, tmpDir)