Ottomata has submitted this change and it was merged.

Change subject: Adding git-fat support for trebuchet deployment
......................................................................


Adding git-fat support for trebuchet deployment

Change-Id: Ib5338575a0240825a87baed9adaa1baafa287754
---
M modules/deployment/files/modules/deploy.py
1 file changed, 56 insertions(+), 0 deletions(-)

Approvals:
  Ottomata: Verified; Looks good to me, approved



diff --git a/modules/deployment/files/modules/deploy.py 
b/modules/deployment/files/modules/deploy.py
index 24ba8df..ffff9b2 100644
--- a/modules/deployment/files/modules/deploy.py
+++ b/modules/deployment/files/modules/deploy.py
@@ -8,6 +8,7 @@
 import urllib
 import os
 import json
+import salt
 
 
 def _get_redis_serv():
@@ -117,6 +118,9 @@
     # checkout_submodules determines whether or not this repo should
     # recursively fetch and checkout submodules.
     config.setdefault('checkout_submodules', False)
+    # If gitfat_enabled is true, git-fat will be initiliazed and
+    # git-fat pull will be run on each target as part of the checkout.
+    config.setdefault('gitfat_enabled', False)
     # dependencies are a set of repositories that should be fetched
     # and checked out before this repo. This is a deprecated feature.
     config.setdefault('dependencies', {})
@@ -306,6 +310,51 @@
         if status != 0:
             return status
     return 0
+
+
+def _gitfat_installed():
+    return salt.utils.which('git-fat')
+
+
+def _init_gitfat(location):
+    '''
+    Runs git fat init at this location.
+
+    :param location: The location on the filesystem to run git fat init
+    :type location: str
+    '''
+    # if it isn't then initialize it now
+    cmd = '/usr/bin/git fat init'
+    return __salt__['cmd.retcode'](cmd, location)
+
+
+# TODO: git fat gc?
+def _update_gitfat(location):
+    '''
+    Runs git-fat pull at this location.
+    If git fat has not been initialized for the
+    repository at this location, _init_gitfat
+    will be called first.
+
+    :param location: The location on the filesystem to run git fat pull
+    :type location: str
+    :rtype int
+    '''
+
+    # Make sure git fat is installed.
+    if _gitfat_installed() != 0:
+        return 40
+
+    # Make sure git fat is initialized.
+    cmd = '/usr/bin/git config --get filter.fat.smudge'
+    if __salt__['cmd.run'](cmd, location) != 'git-fat filter-smudge':
+        status = _init_gitfat(location)
+        if status != 0:
+            return status
+
+    # Run git fat pull.
+    cmd = '/usr/bin/git fat pull'
+    return __salt__['cmd.retcode'](cmd, location)
 
 
 def _clone(config, location, tag, shadow=False):
@@ -600,6 +649,13 @@
         ret = __salt__['cmd.retcode'](cmd, location)
         if ret != 0:
             return 50
+
+    # Trigger git-fat pull if gitfat_enabled
+    if config['gitfat_enabled']:
+        ret = _update_gitfat(location)
+        if ret != 0:
+            return ret
+
     return 0
 
 

-- 
To view, visit https://gerrit.wikimedia.org/r/112944
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ib5338575a0240825a87baed9adaa1baafa287754
Gerrit-PatchSet: 3
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Ottomata <o...@wikimedia.org>
Gerrit-Reviewer: BryanDavis <bda...@wikimedia.org>
Gerrit-Reviewer: Greg Grossmeier <g...@wikimedia.org>
Gerrit-Reviewer: Manybubbles <never...@wikimedia.org>
Gerrit-Reviewer: Ottomata <o...@wikimedia.org>
Gerrit-Reviewer: Ryan Lane <rl...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to