 Issue 6065002532306944:
  Issue 1608 - Introduce HG client module in Puppet  (Closed)
    
  
    Issue 6065002532306944:
  Issue 1608 - Introduce HG client module in Puppet  (Closed) 
  | Left: | ||
| Right: | 
| OLD | NEW | 
|---|---|
| (Empty) | |
| 1 # == Class: hg | |
| 2 # | |
| 3 # A very basic Mercurial client integration. | |
| 4 # | |
| 5 # === Parameters: | |
| 6 # | |
| 7 # Below please find a list of parameters recognized by class hg: | |
| 8 # | |
| 9 # [*path*] | |
| 10 # A $path to pass on to exec{} when invoking commands. Can be overwritten | |
| 11 # in each named type defined by class hg. | |
| 12 # | |
| 13 # [*cwd*] | |
| 14 # A working directory ($cwd) to pass on to exec{} when invoking commands. | |
| 15 # Can be overwritten in each named type defined by class hg. | |
| 16 # | |
| 17 # [*package*] | |
| 18 # The name of the Mercurial (client) package on the target system. | |
| 19 # | |
| 20 # [*post_update*] | |
| 21 # An optional shell command to trigger after a successful hg::update(), | |
| 22 # using the local repository as working directory. | |
| 23 # | |
| 24 # === Examples: | |
| 25 # | |
| 26 # Below please find a set of examples demonstrating the use of class hg: | |
| 27 # | |
| 28 # hg { | |
| 29 # path => '/usr/local/bin', | |
| 30 # post_update => | |
| 31 # shellquote('test', '-e', 'ensure_dependencies.py') + ' && ' + | |
| 32 # shellquote('python', 'ensure_dependencies.py'), | |
| 33 # } | |
| 34 # | |
| 35 # hg::ensure {'/opt/sitescripts': | |
| 36 # source => 'https://hg.adblockplus.org/sitescripts', | |
| 37 # revision => 'tip', | |
| 38 # } | |
| 
Wladimir Palant
2015/01/13 08:10:48
Does this API make sense for us? We typically don'
 
mathias
2015/06/23 10:45:15
Well, the revision parameter is optional (and now
 | |
| 39 # | |
| 40 class hg( | |
| 41 $path = '/usr/local/bin:/usr/bin:/bin', | |
| 42 $cwd = '/', | |
| 43 $package = 'mercurial', | |
| 44 $post_update = '', | |
| 45 $user = 'root') { | |
| 46 | |
| 47 include stdlib | |
| 48 | |
| 49 package {$package: | |
| 50 ensure => installed, | |
| 
Wladimir Palant
2015/01/13 08:10:48
Does a custom path make sense if you require Mercu
 
mathias
2015/06/23 10:45:14
The custom path is also used to ensure the $PATH f
 | |
| 51 } | |
| 52 | |
| 53 Exec { | |
| 54 path => $path, | |
| 55 cwd => $cwd, | |
| 56 } | |
| 57 | |
| 58 define clone( | |
| 59 $source, | |
| 60 $user = $user, | |
| 61 $target = $name) { | |
| 62 | |
| 63 # Allow for accessing $hg::* class parameters | |
| 64 include hg | |
| 65 | |
| 66 $command = shellquote('hg', 'clone', $source, $target) | |
| 67 | |
| 68 exec {$command: | |
| 69 creates => $target, | |
| 70 user => $user, | |
| 71 require => Package[$hg::package], | |
| 72 } | |
| 73 } | |
| 74 | |
| 75 define pull( | |
| 76 $source = '--', | |
| 77 $user = $user, | |
| 78 $target = $name) { | |
| 79 | |
| 80 # Allow for accessing $hg::* class parameters | |
| 81 include hg | |
| 82 | |
| 83 $command = shellquote('hg', '--cwd', $target, 'pull', $source) | |
| 
Wladimir Palant
2015/01/13 08:10:48
Please use -R or --repository rather than --cwd.
 | |
| 84 | |
| 85 exec {$command: | |
| 86 user => $user, | |
| 87 require => Package[$hg::package], | |
| 88 } | |
| 89 } | |
| 90 | |
| 91 define update( | |
| 92 $revision = 'tip', | |
| 
Wladimir Palant
2015/01/13 08:10:48
'tip' isn't a good default, it might be on a branc
 | |
| 93 $user = $user, | |
| 94 $target = $name) { | |
| 95 | |
| 96 # Allow for accessing $hg::* class parameters | |
| 97 include hg | |
| 98 | |
| 99 $command = shellquote('hg', '--cwd', $target, 'pull', '--rev', $revision) | |
| 
Wladimir Palant
2015/01/13 08:10:48
Please use -R or --repository rather than --cwd.
 | |
| 100 | |
| 101 exec {$command: | |
| 102 user => $user, | |
| 103 require => Package[$hg::package], | |
| 104 } | |
| 105 | |
| 106 if $hg::post_update != '' { | |
| 
Wladimir Palant
2015/01/13 08:10:48
Shouldn't this only be executed when an actual upd
 | |
| 107 exec {"$command #post_update": | |
| 108 command => $hg::post_update, | |
| 109 user => $user, | |
| 110 cwd => $target, | |
| 111 require => Exec[$command], | |
| 112 } | |
| 113 } | |
| 114 } | |
| 115 | |
| 116 define ensure( | |
| 117 $source, | |
| 118 $revision = 'tip', | |
| 119 $user = $user, | |
| 120 $target = $name) { | |
| 121 | |
| 122 hg::clone {$name: | |
| 123 source => $source, | |
| 124 user => $user, | |
| 125 target => $target, | |
| 126 } | |
| 
Wladimir Palant
2015/01/13 08:10:48
Should this really be run unconditionally? What if
 | |
| 127 | |
| 128 -> # after clone | |
| 129 hg::pull {$name: | |
| 130 source => $source, | |
| 131 user => $user, | |
| 132 target => $target, | |
| 133 } | |
| 134 | |
| 135 -> # after pull | |
| 136 hg::update {$name: | |
| 137 revision => $revision, | |
| 138 user => $user, | |
| 139 target => $target, | |
| 140 } | |
| 141 } | |
| 142 } | |
| OLD | NEW |