From 9204498fe5fd2a1a6e5af3b4a2aa8fbf8c3139eb Mon Sep 17 00:00:00 2001 From: Alisdair McDiarmid Date: Wed, 10 Jun 2020 16:26:04 -0400 Subject: [PATCH] configs/configload: Remove unused SourceAddr funcs isLocalSourceAddr and isRegistrySourceAddr are also present in internal/initwd/getter.go, and they are unused in this package. --- configs/configload/getter.go | 15 +++++++++++ configs/configload/source_addr.go | 45 ------------------------------- 2 files changed, 15 insertions(+), 45 deletions(-) delete mode 100644 configs/configload/source_addr.go diff --git a/configs/configload/getter.go b/configs/configload/getter.go index 146f04b38..d0c4567b6 100644 --- a/configs/configload/getter.go +++ b/configs/configload/getter.go @@ -151,3 +151,18 @@ func (g reusingGetter) getWithGoGetter(instPath, addr string) (string, error) { // the requested object! return filepath.Clean(finalDir), nil } + +// splitAddrSubdir splits the given address (which is assumed to be a +// registry address or go-getter-style address) into a package portion +// and a sub-directory portion. +// +// The package portion defines what should be downloaded and then the +// sub-directory portion, if present, specifies a sub-directory within +// the downloaded object (an archive, VCS repository, etc) that contains +// the module's configuration files. +// +// The subDir portion will be returned as empty if no subdir separator +// ("//") is present in the address. +func splitAddrSubdir(addr string) (packageAddr, subDir string) { + return getter.SourceDirSubdir(addr) +} diff --git a/configs/configload/source_addr.go b/configs/configload/source_addr.go deleted file mode 100644 index 594cf6406..000000000 --- a/configs/configload/source_addr.go +++ /dev/null @@ -1,45 +0,0 @@ -package configload - -import ( - "strings" - - "github.com/hashicorp/go-getter" - - "github.com/hashicorp/terraform/registry/regsrc" -) - -var localSourcePrefixes = []string{ - "./", - "../", - ".\\", - "..\\", -} - -func isLocalSourceAddr(addr string) bool { - for _, prefix := range localSourcePrefixes { - if strings.HasPrefix(addr, prefix) { - return true - } - } - return false -} - -func isRegistrySourceAddr(addr string) bool { - _, err := regsrc.ParseModuleSource(addr) - return err == nil -} - -// splitAddrSubdir splits the given address (which is assumed to be a -// registry address or go-getter-style address) into a package portion -// and a sub-directory portion. -// -// The package portion defines what should be downloaded and then the -// sub-directory portion, if present, specifies a sub-directory within -// the downloaded object (an archive, VCS repository, etc) that contains -// the module's configuration files. -// -// The subDir portion will be returned as empty if no subdir separator -// ("//") is present in the address. -func splitAddrSubdir(addr string) (packageAddr, subDir string) { - return getter.SourceDirSubdir(addr) -}