saltstack/salt — pull request #18400 by terminalmage (2014-11-22 01:04:43+00:00)
Title: Fix gitfs serving symlinks

This fixes #17700 by detecting when a blob refers to a symlink, and following
the symlink. I set a max recursion depth of 100, to prevent symlinks which
point to each other from causing an infinite loop.

Info for QA testing:

**Set the following in the master config file:**

```
fileserver_backend:
- git

gitfs_provider: gitpython

gitfs_remotes:
- https://github.com/terminalmage/salt-bootstrap.git:
- base: symlink-test
```

**Run the following states:**

```
salt myminion state.single file.managed /tmp/mybootstrap.sh source=salt://subdir/mybootstrap.sh
salt myminion state.single file.managed /tmp/mybootstrap.sh source=salt://salt-bootstrap.sh
salt myminion state.single file.managed /tmp/mybootstrap.sh source=salt://bootstrap-salt.sh
salt myminion state.single file.managed /tmp/mybootstrap.sh source=salt://thisfiledoesnotexist
```

* The source URL in the first state is a 2-level symlink, pointing up a directory to salt-bootstrap.sh, which is itself a symlink of bootstrap-salt.sh.
* The source URL in the second state is symlinked to bootstrap-salt.sh in the same directory.
* The source URL in the third state points to an actual file.
* The source URL in the fourth state points to a nonexistant file.

The first three should work (with the second and third just saying that the file is in the correct state), while the fourth one should fail.

This test should be repeated with ``gitfs_provider`` set to ``pygit2`` and ``dulwich``. See the [GitFS Walkthrough](http://docs.saltstack.com/en/latest/topics/tutorials/gitfs.html#installing-dependencies) for information on installing the dependencies.