aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/github.com/hashicorp/go-getter/source.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/hashicorp/go-getter/source.go')
-rw-r--r--vendor/github.com/hashicorp/go-getter/source.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/vendor/github.com/hashicorp/go-getter/source.go b/vendor/github.com/hashicorp/go-getter/source.go
index 4d5ee3c..c63f2bb 100644
--- a/vendor/github.com/hashicorp/go-getter/source.go
+++ b/vendor/github.com/hashicorp/go-getter/source.go
@@ -1,6 +1,8 @@
1package getter 1package getter
2 2
3import ( 3import (
4 "fmt"
5 "path/filepath"
4 "strings" 6 "strings"
5) 7)
6 8
@@ -34,3 +36,27 @@ func SourceDirSubdir(src string) (string, string) {
34 36
35 return src, subdir 37 return src, subdir
36} 38}
39
40// SubdirGlob returns the actual subdir with globbing processed.
41//
42// dst should be a destination directory that is already populated (the
43// download is complete) and subDir should be the set subDir. If subDir
44// is an empty string, this returns an empty string.
45//
46// The returned path is the full absolute path.
47func SubdirGlob(dst, subDir string) (string, error) {
48 matches, err := filepath.Glob(filepath.Join(dst, subDir))
49 if err != nil {
50 return "", err
51 }
52
53 if len(matches) == 0 {
54 return "", fmt.Errorf("subdir %q not found", subDir)
55 }
56
57 if len(matches) > 1 {
58 return "", fmt.Errorf("subdir %q matches multiple paths", subDir)
59 }
60
61 return matches[0], nil
62}