]> git.immae.eu Git - github/fretlink/terraform-provider-statuscake.git/blame - vendor/github.com/hashicorp/terraform/configs/configload/source_addr.go
Upgrade to 0.12
[github/fretlink/terraform-provider-statuscake.git] / vendor / github.com / hashicorp / terraform / configs / configload / source_addr.go
CommitLineData
107c1cdb
ND
1package configload
2
3import (
4 "strings"
5
6 "github.com/hashicorp/go-getter"
7
8 "github.com/hashicorp/terraform/registry/regsrc"
9)
10
11var localSourcePrefixes = []string{
12 "./",
13 "../",
14 ".\\",
15 "..\\",
16}
17
18func 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
27func 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.
43func splitAddrSubdir(addr string) (packageAddr, subDir string) {
44 return getter.SourceDirSubdir(addr)
45}