IMPORTANT: If specifying a cache_root, understand that this is also where the remotes will be cloned. A non-default cache_root is only really designed right now for winrepo, as its repos need to be checked out into the winrepo locations and not within the cachedir.
(
self,
opts,
remotes=None,
per_remote_overrides=(),
per_remote_only=PER_REMOTE_ONLY,
global_only=GLOBAL_ONLY,
git_providers=None,
cache_root=None,
init_remotes=True,
)
| 3064 | """ |
| 3065 | |
| 3066 | def __init__( |
| 3067 | self, |
| 3068 | opts, |
| 3069 | remotes=None, |
| 3070 | per_remote_overrides=(), |
| 3071 | per_remote_only=PER_REMOTE_ONLY, |
| 3072 | global_only=GLOBAL_ONLY, |
| 3073 | git_providers=None, |
| 3074 | cache_root=None, |
| 3075 | init_remotes=True, |
| 3076 | ): |
| 3077 | """ |
| 3078 | IMPORTANT: If specifying a cache_root, understand that this is also |
| 3079 | where the remotes will be cloned. A non-default cache_root is only |
| 3080 | really designed right now for winrepo, as its repos need to be checked |
| 3081 | out into the winrepo locations and not within the cachedir. |
| 3082 | |
| 3083 | As of the 2018.3 release cycle, the classes used to interface with |
| 3084 | Pygit2 and GitPython can be overridden by passing the git_providers |
| 3085 | argument when spawning a class instance. This allows for one to write |
| 3086 | classes which inherit from salt.utils.gitfs.Pygit2 or |
| 3087 | salt.utils.gitfs.GitPython, and then direct one of the GitBase |
| 3088 | subclasses (GitFS, GitPillar, WinRepo) to use the custom class. For |
| 3089 | example: |
| 3090 | |
| 3091 | .. code-block:: Python |
| 3092 | |
| 3093 | import salt.utils.gitfs |
| 3094 | from salt.fileserver.gitfs import PER_REMOTE_OVERRIDES, PER_REMOTE_ONLY |
| 3095 | |
| 3096 | class CustomPygit2(salt.utils.gitfs.Pygit2): |
| 3097 | def fetch_remotes(self): |
| 3098 | ... |
| 3099 | Alternate fetch behavior here |
| 3100 | ... |
| 3101 | |
| 3102 | git_providers = { |
| 3103 | 'pygit2': CustomPygit2, |
| 3104 | 'gitpython': salt.utils.gitfs.GitPython, |
| 3105 | } |
| 3106 | |
| 3107 | gitfs = salt.utils.gitfs.GitFS( |
| 3108 | __opts__, |
| 3109 | __opts__['gitfs_remotes'], |
| 3110 | per_remote_overrides=PER_REMOTE_OVERRIDES, |
| 3111 | per_remote_only=PER_REMOTE_ONLY, |
| 3112 | git_providers=git_providers) |
| 3113 | |
| 3114 | gitfs.fetch_remotes() |
| 3115 | """ |
| 3116 | self.opts = opts |
| 3117 | if git_providers is not None: |
| 3118 | self.git_providers = git_providers |
| 3119 | else: |
| 3120 | self.git_providers = GIT_PROVIDERS |
| 3121 | self.verify_provider() |
| 3122 | if cache_root is not None: |
| 3123 | self.cache_root = self.remote_root = cache_root |
nothing calls this directly
no test coverage detected