 Issue 29526640:
  #3044 - Introduce class adblockplus::mercurial  (Closed)
    
  
    Issue 29526640:
  #3044 - Introduce class adblockplus::mercurial  (Closed) 
  | Index: modules/adblockplus/manifests/mercurial/extension.pp | 
| =================================================================== | 
| new file mode 100644 | 
| --- /dev/null | 
| +++ b/modules/adblockplus/manifests/mercurial/extension.pp | 
| @@ -0,0 +1,75 @@ | 
| +# == Type: adblockplus::mercurial::extension | 
| +# | 
| +# Setup rotation for a particular log file. | 
| +# | 
| +# === Parameters: | 
| 
mathias
2017/08/24 16:40:52
Please document parameters $config and $package, t
 
f.lopez
2017/08/24 17:45:58
Acknowledged.
 | 
| +# | 
| +# === Examples: | 
| +# | 
| +# adblockplus::mercurial::extension {'example': | 
| +# name => 'pager', | 
| +# config => { | 
| +# content => join([ | 
| +# '[extensions]', | 
| +# 'pager = ', | 
| +# '[pager]', | 
| +# 'pager = LESS=FSRX less', | 
| +# ], "\n"), | 
| +# } | 
| +# } | 
| +# | 
| +# adblockplus::mercurial::extension {'hggit': | 
| +# package => { | 
| +# 'ensure' => 'latest', | 
| +# 'name' => 'hg-git', | 
| +# 'provider' => 'pip', | 
| +# }, | 
| +# } | 
| +# | 
| +# adblockplus::mercurial::extension {'hgext.git': | 
| +# package => { | 
| +# 'ensure' => 'absent', | 
| +# 'name' => 'mercurial-git', | 
| +# }, | 
| +# } | 
| +# | 
| +define adblockplus::mercurial::extension ( | 
| + $config = {}, | 
| + $package = undef, | 
| +) { | 
| + | 
| + include adblockplus::mercurial | 
| + include stdlib | 
| + | 
| + # https://docs.puppet.com/puppet/latest/lang_conditional.html#selectors | 
| + # https://docs.puppet.com/puppet/latest/types/file.html#file-attribute-content | 
| + # https://docs.puppet.com/puppet/latest/types/file.html#file-attribute-source | 
| + $default_content = $config['source'] ? { | 
| + undef => template('adblockplus/mercurial/hgext.erb'), | 
| + default => undef, | 
| + } | 
| + | 
| + # https://forge.puppet.com/puppetlabs/stdlib#ensure_resource | 
| + # https://forge.puppet.com/puppetlabs/stdlib#merge | 
| + ensure_resource('file', "$name.rc", merge({ | 
| + content => $default_content, | 
| + ensure => ensure_file_state($adblockplus::mercurial::ensure), | 
| + path => "/etc/mercurial/hgrc.d/$name.rc", | 
| + }, $config)) | 
| + | 
| + # https://docs.puppet.com/puppet/latest/lang_relationships.html | 
| + File["$name.rc"] <- Package['mercurial'] | 
| + | 
| + ensure_resource('package', 'python-dev') | 
| 
mathias
2017/08/24 16:40:52
?
 
f.lopez
2017/08/24 17:45:58
This is needed for installing pip packages (for hg
 | 
| + | 
| + # https://docs.puppet.com/puppet/latest/function.html#defined | 
| + if defined('$package') { | 
| + | 
| + ensure_resource('package', $name, merge({ | 
| + ensure => $adblockplus::mercurial::ensure, | 
| + require => Package['python-dev'], | 
| + }, $package)) | 
| + | 
| + Package[$name] <- Package['mercurial'] | 
| + } | 
| +} |