Commit Graph

24 Commits

Author SHA1 Message Date
James Bardin 0d10564a74 remove the registryDetector
The detection of registry modules will have to happen in mutliple
phases. The go-getter interface requires that the detector return the
final URL, while we won't know that until we verify which version we
need. This leaves the regisry sources broken, to be re-integrated in a
following commit.
2017-10-27 09:08:15 -04:00
James Bardin a5c86aeff6 Use the new regsrc and response packages
Adds basic detector for registry module source strings. While this isn't
a thorough validation, this will eliminate anything that is definitely
not a registry module, and split out our host and module id strings.

lookupModuleVersions interrogates the registry for the available
versions of a particular module and the tree of dependencies.
2017-10-27 09:08:15 -04:00
James Bardin 1f44fd8eb2 move getStorage to moduleStorage too
Add a test to ensure we don't store different modules with the same
relative path in the same location.
2017-10-27 09:08:15 -04:00
James Bardin 0962792257 surface registry errors to the user
Now that we can enforce local modules being relative or absolute paths,
we can be assured that any module source matching a registry pattern
must be found in the registry. This allows us to surface more useful
errors to the user, rather than simply stating that a source string
isn't valid.
2017-10-27 09:08:15 -04:00
James Bardin a359c4ee2f check the registry detector before local files
Breaking change for 0.11.

Local files were checked first to avoid the possibility of breaking a
module with a local source that looked like a registry ID. Now we can
enfore that any source iwth the pattern "namespace/identifier/provider"
must be a registry module.
2017-10-27 09:08:15 -04:00
James Bardin 6088270c66 skip lookup for paths starting with ../
Prevent an extra registry lookup for sources starting with ../
2017-10-27 09:08:15 -04:00
James Bardin 1fbb2d611a remove extra slash from registry urls
A refactor introduced an extra `/` in the download url, which causes an
extra redirect during discovery.

Improve a registry test to verify that detection doesn't require the
registry after the modules have been fetched.
2017-09-28 14:45:02 -04:00
James Bardin f9fb2b4c9e move local module detection ahead of the registry
The getter.FileDetector was intended to be the final detector, only
converting a path to a file URL and returning a true in all cases. We
want to check for a local module before checking the registry so no
local modules that happen to match a registry module are broken.

Wrap the getter.FileDetector to check the module source's existence
before delegating the search to the registry.
2017-09-15 16:16:28 -04:00
James Bardin a83ff57aea Add registry detector
Add a getter.Detector for detecting registry modules and looking up
the download location of the latest version. This is essentially a
temporary API until constraint solving is supported by the registry, as
then we'll have to supply the full set of known contraints to the
registry at once for resolution and we will fetch specific versions of
modules.
2017-09-15 16:16:28 -04:00
James Bardin 558e023e26 Don't try to copy files over themselves
When copying a config module, make sure the full path for src and dst
files don't match, and also check the inode in case we resolved a
different path to the same file.

Make a note about the unsafe usage of reusing a tempDir path.
2016-06-22 11:25:42 -04:00
Mitchell Hashimoto 344e7c26b5 fix a bunch of tests from go-getter import 2015-10-15 13:48:58 -07:00
Mitchell Hashimoto 06f4ac8166 config/module: use go-getter 2015-10-15 13:36:58 -07:00
Emil Hessman e7bbbfb098 helper/url: add Windows 'safe' URL Parse wrapper
Pull out the urlParse function, which was introduced in config/module,
into a helper package.
2015-02-05 11:16:54 +01:00
Emil Hessman d5a49363d7 config/module: handle absolute file paths on Windows
Using url.Parse to parse an absolute file path on Windows yields
a URL type where the Path element is prefixed by a slash.

For example, parsing "file:///C:/Users/user" gives a URL type
with Path:"/C:/Users/user".

According to golang.org/issue/6027, the parsing is correct as is.

The leading slash on the Path must be eliminated before any file
operations.

This commit introduces a urlParse function which wraps the url.Parse
functionality and removes the leading slash in Path for absolute file
paths on Windows.

Fixes config/module test failures on Windows.
2015-01-27 23:18:47 +01:00
Mitchell Hashimoto 369ba8cf07 config/module: fix issue where Get was copying subdir contents twice 2014-10-13 17:38:27 -07:00
Mitchell Hashimoto 9689a34b28 config/module: GetCopy 2014-09-26 16:21:33 -07:00
Mitchell Hashimoto c91fd76fe8 config/module: Get can support subdirs 2014-09-26 16:11:13 -07:00
Mitchell Hashimoto 21d90dcf4f config/module: HTTP supports subdirs 2014-09-26 15:22:26 -07:00
Mitchell Hashimoto 7aa30fdf25 config: support subdirectories with the "//" syntax 2014-09-26 14:56:04 -07:00
Mitchell Hashimoto 9a626b3e8c config/module: support HTTP protocol 2014-09-16 13:44:12 -07:00
Mitchell Hashimoto 7e94f7d4a9 config/module: Mercurial support 2014-09-16 09:34:23 -07:00
Mitchell Hashimoto acb6d12a75 config/module: support forced getters with TYPE::URL syntax 2014-09-15 23:48:56 -07:00
Mitchell Hashimoto cf4885d2fd config/module: git support 2014-09-15 23:32:30 -07:00
Mitchell Hashimoto bb22090040 config/module: start, lots of initial work 2014-09-13 17:45:56 -07:00