saltstack/salt — pull request #10468 by terminalmage (2014-02-15 07:06:49+00:00)
Title: Add gitfs "mountpoints" and per-remote config params

**NOTE: I am still testing this, so it is still a work-in-progress. Please hold off on merging.**

Mountpoints!
============

This pull request adds a new "mountpoint" feature for gitfs. While ``gitfs_root`` parameter will tell salt to serve up files starting at a subdirectory of the remote repository, ``gitfs_mountpoint`` will tell the fileserver that all paths being served will have the mountpoint prepended to them. Thus, a gitfs remote can be pinned to a subdirectory. This allows one to add a gitfs remote that serves up files from ``salt://foo/bar/baz`` without needing to have ``foo/bar/baz/`` exist at the root of the git repository.

Per-remote config parameters!
=============================

This also establishes per-remote config parameters. ``gitfs_root`` and ``gitfs_mountpoint`` are treated as global defaults, but they can be overridden on a per-remote basis. So, assuming the below configuration...

```yaml
gitfs_remotes:
- https://foo.com/foo.git
- https://foo.com/bar.git:
- root: salt
- mountpoint: salt://foo/bar/baz
- https://foo.com/baz.git:
- root: salt
```

1. **https://foo.com/foo.git** will act like in prior versions of Salt (in other words, backwards compatibility is preserved). Since neither ``gitfs_root`` nor ``gitfs_mountpoint`` are set, all files from this repo will be exposed to the salt fileserver, and they will be served starting at ``salt://`` (as has been the default in all previous versions of Salt).
2. **https://foo.com/bar.git** will serve files from its ``salt`` subdirectory, and all child directories. Its files will be made available under ``salt://foo/bar/baz``.
3. **https://foo.com/baz.git** will serve files from its ``salt`` subdirectory, and all child directories. Its files will be made available under ``salt://`` since no mountpoint is defined (and no global ``gitfs_mountpoint`` is defined).

This feature has yet to be sufficiently documented, but that can be done in the coming weeks.

Addional goodies in this pull req:
==================================

1. Since we are now hashing the remote URIs to ensure that ordering of gitfs_remotes does not matter, I have added a file called remote_map.txt that is written to ``$cachedir/gitfs/remote_map.txt`` whenever a new remote is added. This file will look like the following:

```
# gitfs_remote map as of 14 Feb 2014 23:00:55.469790
95e2b92ca5438b7c4deb005f2ad570af = file:///home/erik/git/salt
```

2. The ``index`` kwarg in ``find_file()`` is no longer necessary, as we are hashing the remote URIs. Nothing in fileclient.py uses this kwarg anymore. References to it have been removed.