Skip to content

Commit

Permalink
Support formatter in repo url
Browse files Browse the repository at this point in the history
The repo url in project.yml can now contain {} or {0}. This value is
substituted with the name of module. If no formatter directions are
present in the repo, the name will be appended.

This changes supports repos of the form https://gitlab.com/foo/bar.git
  • Loading branch information
bartv committed Jun 12, 2018
1 parent b08cb88 commit 1efc7e9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 2 additions & 3 deletions docs/guides/configurationmodel.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,8 @@ modules. project.yml defines the following settings:
* master: Use the master branch.

* ``repo`` This key requires a list (a yaml list) of repositories where Inmanta can find
modules. The git url of a module is created by appending the name of the module to the repo
in this list. Inmanta tries to clone a module in the order in which it is defined in this
value.
modules. Inmanta creates the git repo url by formatting {} or {0} with the name of the repo. If no formatter is present it
appends the name of the module. Inmanta tries to clone a module in the order in which it is defined in this value.
* ``requires`` Model files import other modules. These imports do not determine a version, this
is based on the install_model setting. Modules and projects can constrain a version in the
requires setting. Similar to the module, version constraints are defined using `PEP440 syntax
Expand Down
6 changes: 5 additions & 1 deletion src/inmanta/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,11 @@ def __init__(self, baseurl):

def clone(self, name: str, dest: str) -> bool:
try:
gitprovider.clone(self.baseurl + name, os.path.join(dest, name))
url = self.baseurl.format(name)
if url == self.baseurl:
url = self.baseurl + name

gitprovider.clone(url, os.path.join(dest, name))
return True
except Exception:
LOGGER.debug("could not clone repo", exc_info=True)
Expand Down

0 comments on commit 1efc7e9

Please sign in to comment.