diff options
author | Nathan Dench <ndenc2@gmail.com> | 2019-05-24 15:16:44 +1000 |
---|---|---|
committer | Nathan Dench <ndenc2@gmail.com> | 2019-05-24 15:16:44 +1000 |
commit | 107c1cdb09c575aa2f61d97f48d8587eb6bada4c (patch) | |
tree | ca7d008643efc555c388baeaf1d986e0b6b3e28c /vendor/github.com/hashicorp/terraform/configs/configload/source_addr.go | |
parent | 844b5a68d8af4791755b8f0ad293cc99f5959183 (diff) | |
download | terraform-provider-statuscake-107c1cdb09c575aa2f61d97f48d8587eb6bada4c.tar.gz terraform-provider-statuscake-107c1cdb09c575aa2f61d97f48d8587eb6bada4c.tar.zst terraform-provider-statuscake-107c1cdb09c575aa2f61d97f48d8587eb6bada4c.zip |
Upgrade to 0.12
Diffstat (limited to 'vendor/github.com/hashicorp/terraform/configs/configload/source_addr.go')
-rw-r--r-- | vendor/github.com/hashicorp/terraform/configs/configload/source_addr.go | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/vendor/github.com/hashicorp/terraform/configs/configload/source_addr.go b/vendor/github.com/hashicorp/terraform/configs/configload/source_addr.go new file mode 100644 index 0000000..594cf64 --- /dev/null +++ b/vendor/github.com/hashicorp/terraform/configs/configload/source_addr.go | |||
@@ -0,0 +1,45 @@ | |||
1 | package configload | ||
2 | |||
3 | import ( | ||
4 | "strings" | ||
5 | |||
6 | "github.com/hashicorp/go-getter" | ||
7 | |||
8 | "github.com/hashicorp/terraform/registry/regsrc" | ||
9 | ) | ||
10 | |||
11 | var localSourcePrefixes = []string{ | ||
12 | "./", | ||
13 | "../", | ||
14 | ".\\", | ||
15 | "..\\", | ||
16 | } | ||
17 | |||
18 | func isLocalSourceAddr(addr string) bool { | ||
19 | for _, prefix := range localSourcePrefixes { | ||
20 | if strings.HasPrefix(addr, prefix) { | ||
21 | return true | ||
22 | } | ||
23 | } | ||
24 | return false | ||
25 | } | ||
26 | |||
27 | func isRegistrySourceAddr(addr string) bool { | ||
28 | _, err := regsrc.ParseModuleSource(addr) | ||
29 | return err == nil | ||
30 | } | ||
31 | |||
32 | // splitAddrSubdir splits the given address (which is assumed to be a | ||
33 | // registry address or go-getter-style address) into a package portion | ||
34 | // and a sub-directory portion. | ||
35 | // | ||
36 | // The package portion defines what should be downloaded and then the | ||
37 | // sub-directory portion, if present, specifies a sub-directory within | ||
38 | // the downloaded object (an archive, VCS repository, etc) that contains | ||
39 | // the module's configuration files. | ||
40 | // | ||
41 | // The subDir portion will be returned as empty if no subdir separator | ||
42 | // ("//") is present in the address. | ||
43 | func splitAddrSubdir(addr string) (packageAddr, subDir string) { | ||
44 | return getter.SourceDirSubdir(addr) | ||
45 | } | ||